added message sending and PM channel resolving

This commit is contained in:
hydrabolt
2015-08-25 15:44:18 +01:00
parent 4f179901c6
commit 5f812f7c90
5 changed files with 579 additions and 107 deletions

View File

@@ -1,6 +1,25 @@
var User = require("./user.js").User;
exports.PMChannel = function(user, id){
this.user = new User(user);
this.id = id;
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){
for(var message of this.messages){
if(message[key] === value){
return message;
}
}
return null;
}
}
module.exports = PMChannel;