mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 18:13:29 +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 client = this.client;
|
||||||
|
|
||||||
const channel = client.channels.get((data instanceof Array ? data[0] : data).channel_id);
|
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) {
|
if (channel) {
|
||||||
|
const member = channel.guild ? channel.guild.member(user) : null;
|
||||||
if (data instanceof Array) {
|
if (data instanceof Array) {
|
||||||
const messages = new Array(data.length);
|
const messages = new Array(data.length);
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
messages[i] = channel._cacheMessage(new Message(channel, data[i], client));
|
messages[i] = channel._cacheMessage(new Message(channel, data[i], client));
|
||||||
}
|
}
|
||||||
channel.lastMessageID = messages[messages.length - 1].id;
|
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 {
|
return {
|
||||||
messages,
|
messages,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const message = channel._cacheMessage(new Message(channel, data, client));
|
const message = channel._cacheMessage(new Message(channel, data, client));
|
||||||
channel.lastMessageID = data.id;
|
channel.lastMessageID = data.id;
|
||||||
|
if (user) user.lastMessageID = data.id;
|
||||||
|
if (member) member.lastMessageID = data.id;
|
||||||
return {
|
return {
|
||||||
message,
|
message,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,6 +33,12 @@ class GuildMember {
|
|||||||
|
|
||||||
this._roles = [];
|
this._roles = [];
|
||||||
if (data) this.setup(data);
|
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) {
|
setup(data) {
|
||||||
|
|||||||
@@ -49,6 +49,12 @@ class User {
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.bot = Boolean(data.bot);
|
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) {
|
patch(data) {
|
||||||
|
|||||||
Reference in New Issue
Block a user