Files
discord.js/src/PMChannel.js
hydrabolt e7adc3ddbf More documentation and updated some PM Channel code
The PM Channel will now also trunc messages and cap the array size
2015-09-30 18:23:21 +01:00

34 lines
627 B
JavaScript

class PMChannel {
constructor(data, client) {
this.user = client.getUser("id", data.recipient.id);
this.id = data.id;
this.messages = [];
}
addMessage(data){
if(!this.getMessage("id", data.id)){
this.messages.push(data);
}
return this.getMessage("id", data.id);
}
getMessage(key, value){
if(this.messages.length > 1000){
this.messages.splice(0,1);
}
for(var message of this.messages){
if(message[key] === value){
return message;
}
}
return null;
}
get isPrivate(){
return true;
}
}
module.exports = PMChannel;