fix: Convert lastMessage to getters (#2384)

* convert lastMessage to getters

* fix bug in pr

* requested changes
This commit is contained in:
bdistin
2018-03-08 10:19:43 -06:00
committed by Isabella
parent 799eea957e
commit 630009f3cf
7 changed files with 40 additions and 14 deletions

View File

@@ -59,10 +59,10 @@ class User extends Base {
this.lastMessageID = null;
/**
* The Message object of the last message sent by the user, if one was sent
* @type {?Message}
* The ID of the channel for the last message sent by the user, if one was sent
* @type {?Snowflake}
*/
this.lastMessage = null;
this.lastMessageChannelID = null;
}
/**
@@ -83,6 +83,16 @@ class User extends Base {
return new Date(this.createdTimestamp);
}
/**
* The Message object of the last message sent by the user, if one was sent
* @type {?Message}
* @readonly
*/
get lastMessage() {
const channel = this.client.channels.get(this.lastMessageChannelID);
return (channel && channel.messages.get(this.lastMessageID)) || null;
}
/**
* The presence of this user
* @type {Presence}