From b177aefdd67a0b0409fde3707ec5d5439e70c17e Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Tue, 6 Dec 2016 22:46:32 -0600 Subject: [PATCH] add user/member lastMessageID (#959) * add user.lastMessageID * stupid * add member.lastMessageID --- src/client/actions/MessageCreate.js | 6 ++++++ src/structures/GuildMember.js | 6 ++++++ src/structures/User.js | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/src/client/actions/MessageCreate.js b/src/client/actions/MessageCreate.js index d3ac7f22d..00fc1e93d 100644 --- a/src/client/actions/MessageCreate.js +++ b/src/client/actions/MessageCreate.js @@ -6,19 +6,25 @@ class MessageCreateAction extends Action { const client = this.client; const channel = client.channels.get((data instanceof Array ? data[0] : data).channel_id); + const user = client.users.get((data instanceof Array ? data[0] : data).author.id); if (channel) { + const member = channel.guild ? channel.guild.member(user) : null; if (data instanceof Array) { const messages = new Array(data.length); for (let i = 0; i < data.length; i++) { messages[i] = channel._cacheMessage(new Message(channel, data[i], client)); } channel.lastMessageID = messages[messages.length - 1].id; + if (user) user.lastMessageID = messages[messages.length - 1].id; + if (member) member.lastMessageID = messages[messages.length - 1].id; return { messages, }; } else { const message = channel._cacheMessage(new Message(channel, data, client)); channel.lastMessageID = data.id; + if (user) user.lastMessageID = data.id; + if (member) member.lastMessageID = data.id; return { message, }; diff --git a/src/structures/GuildMember.js b/src/structures/GuildMember.js index 5a221c6f1..70746c330 100644 --- a/src/structures/GuildMember.js +++ b/src/structures/GuildMember.js @@ -33,6 +33,12 @@ class GuildMember { this._roles = []; if (data) this.setup(data); + + /** + * The ID of the last message sent by the member in their guild, if one was sent. + * @type {?string} + */ + this.lastMessageID = null; } setup(data) { diff --git a/src/structures/User.js b/src/structures/User.js index 3bbc85f0f..54c57ee08 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -49,6 +49,12 @@ class User { * @type {boolean} */ this.bot = Boolean(data.bot); + + /** + * The ID of the last message sent by the user, if one was sent. + * @type {?string} + */ + this.lastMessageID = null; } patch(data) {