mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-04-13 07:17:12 +03:00
Include user discriminators in savefile (#55)
Co-authored-by: chylex <contact@chylex.com>
This commit is contained in:
parent
e9679c616f
commit
7fb479a1b9
@ -27,11 +27,14 @@ a
|
||||
t
|
||||
d
|
||||
te
|
||||
tag
|
||||
author
|
||||
type
|
||||
state
|
||||
id
|
||||
username
|
||||
bot
|
||||
discriminator
|
||||
timestamp
|
||||
content
|
||||
editedTimestamp
|
||||
|
@ -6,7 +6,8 @@
|
||||
* meta: {
|
||||
* users: {
|
||||
* <discord user id>: {
|
||||
* name: <user name>
|
||||
* name: <user name>,
|
||||
* tag: <user discriminator> // only present if not a bot
|
||||
* }, ...
|
||||
* },
|
||||
*
|
||||
@ -102,12 +103,16 @@ class SAVEFILE{
|
||||
return parsedObj && typeof parsedObj.meta === "object" && typeof parsedObj.data === "object";
|
||||
}
|
||||
|
||||
findOrRegisterUser(userId, userName){
|
||||
findOrRegisterUser(userId, userName, userDiscriminator){
|
||||
if (!(userId in this.meta.users)){
|
||||
this.meta.users[userId] = {
|
||||
"name": userName
|
||||
};
|
||||
|
||||
if (userDiscriminator){
|
||||
this.meta.users[userId].tag = userDiscriminator;
|
||||
}
|
||||
|
||||
this.meta.userindex.push(userId);
|
||||
return this.tmp.userlookup[userId] = this.meta.userindex.length-1;
|
||||
}
|
||||
@ -163,8 +168,10 @@ class SAVEFILE{
|
||||
}
|
||||
|
||||
convertToMessageObject(discordMessage){
|
||||
var author = discordMessage.author;
|
||||
|
||||
var obj = {
|
||||
u: this.findOrRegisterUser(discordMessage.author.id, discordMessage.author.username),
|
||||
u: this.findOrRegisterUser(author.id, author.username, author.bot ? null : author.discriminator),
|
||||
t: discordMessage.timestamp.toDate().getTime()
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user