fix(TextBasedChannel): added missing lastMessage functionality in textchannels (#2999)

This commit is contained in:
Drahcirius
2018-12-23 23:16:50 -05:00
committed by Isabella
parent 2aa8e1d9c1
commit 7186c91063
2 changed files with 10 additions and 2 deletions

View File

@@ -16,7 +16,6 @@ class MessageCreateAction extends Action {
}
const lastMessage = messages[messages.length - 1];
channel.lastMessageID = lastMessage.id;
channel.lastMessage = lastMessage;
if (user) {
user.lastMessageID = lastMessage.id;
user.lastMessage = lastMessage;
@@ -31,7 +30,6 @@ class MessageCreateAction extends Action {
} else {
const message = channel._cacheMessage(new Message(channel, data, client));
channel.lastMessageID = data.id;
channel.lastMessage = message;
if (user) {
user.lastMessageID = data.id;
user.lastMessage = message;

View File

@@ -395,6 +395,15 @@ class TextBasedChannel {
return 0;
}
/**
* The Message object of the last message in the channel, if one was sent
* @type {?Message}
* @readonly
*/
get lastMessage() {
return this.messages.get(this.lastMessageID) || null;
}
/**
* The date when the last pinned message was pinned, if there was one
* @type {?Date}
@@ -599,6 +608,7 @@ exports.applyToClass = (structure, full = false, ignore = []) => {
'fetchMessages',
'fetchMessage',
'search',
'lastMessage',
'lastPinAt',
'bulkDelete',
'startTyping',