Fixed PM Channel bug, 3.8.2

Clients no longer crashed when receiving PM channel messages.
This commit is contained in:
hydrabolt
2015-10-10 11:43:31 +01:00
parent 15b78b0108
commit 3578178941
8 changed files with 43 additions and 34 deletions

View File

@@ -3,6 +3,7 @@ class PMChannel {
this.user = client.getUser("id", data.recipient.id);
this.id = data.id;
this.messages = [];
this.client = client;
}
addMessage(data){

View File

@@ -11,11 +11,10 @@ class Channel {
this.messages = [];
this.roles = [];
for (var role of data.permission_overwrites) {
this.roles.push( new ChannelPermissions(role, this) );
}
if(data.permission_overwrites)
for (var role of data.permission_overwrites) {
this.roles.push( new ChannelPermissions(role, this) );
}
//this.isPrivate = isPrivate; //not sure about the implementation of this...
}

View File

@@ -12,7 +12,13 @@ class Message{
this.editedTimestamp = data.edited_timestamp;
this.content = data.content.trim();
this.channel = channel;
this.author = this.channel.server.getMember("id", author.id);
if(this.isPrivate){
this.author = this.channel.client.getUser("id", author.id);
}else{
this.author = this.channel.server.getMember("id", author.id) || this.channel.client.getUser("id", author.id);
}
this.attachments = data.attachments;
}