mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 11:03:30 +01:00
fixed how channels and users are cached
This commit is contained in:
@@ -5,6 +5,7 @@ class Channel {
|
||||
this.name = data.name;
|
||||
this.type = data.type;
|
||||
this.id = data.id;
|
||||
this.messages = [];
|
||||
//this.isPrivate = isPrivate; //not sure about the implementation of this...
|
||||
}
|
||||
|
||||
@@ -15,6 +16,22 @@ class Channel {
|
||||
equals(object) {
|
||||
return object.id === this.id;
|
||||
}
|
||||
|
||||
addMessage(data){
|
||||
if(!this.getMessage("id", data.id)){
|
||||
this.messages.push(data);
|
||||
}
|
||||
return this.getMessage("id", data.id);
|
||||
}
|
||||
|
||||
getMessage(key, value){
|
||||
for(var message of this.messages){
|
||||
if(message[key] === value){
|
||||
return message;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user