mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
add user/member lastMessageID (#959)
* add user.lastMessageID * stupid * add member.lastMessageID
This commit is contained in:
committed by
Schuyler Cebulskie
parent
050d3f9303
commit
b177aefdd6
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user