mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 09:33:32 +01:00
Add Message Reaction me
This commit is contained in:
@@ -155,6 +155,13 @@ class Message {
|
||||
* @type {Collection<string, MessageReaction>}
|
||||
*/
|
||||
this.reactions = new Collection();
|
||||
|
||||
if (data.reactions && data.reactions.length > 0) {
|
||||
for (const reaction of data.reactions) {
|
||||
const id = reaction.emoji.id ? `${reaction.emoji.name}:${reaction.emoji.id}` : reaction.emoji.name;
|
||||
this.reactions.set(id, new MessageReaction(this, reaction.emoji, reaction.count, reaction.me));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_addReaction(emoji, user) {
|
||||
@@ -162,8 +169,9 @@ class Message {
|
||||
let reaction;
|
||||
if (this.reactions.has(emojiID)) {
|
||||
reaction = this.reactions.get(emojiID);
|
||||
if (!reaction.me) reaction.me = user.id === this.client.user.id;
|
||||
} else {
|
||||
reaction = new MessageReaction(this, emoji, 0);
|
||||
reaction = new MessageReaction(this, emoji, 0, user.id === this.client.user.id);
|
||||
this.reactions.set(emojiID, reaction);
|
||||
}
|
||||
if (!reaction.users.has(user.id)) {
|
||||
@@ -181,6 +189,9 @@ class Message {
|
||||
if (reaction.users.has(user.id)) {
|
||||
reaction.users.delete(user.id);
|
||||
reaction.count--;
|
||||
if (user.id === this.client.user.id) {
|
||||
reaction.me = false;
|
||||
}
|
||||
return reaction;
|
||||
}
|
||||
}
|
||||
@@ -236,6 +247,15 @@ class Message {
|
||||
if (chan) this.mentions.channels.set(chan.id, chan);
|
||||
}
|
||||
}
|
||||
if (data.reactions) {
|
||||
this.reactions = new Collection();
|
||||
if (data.reactions.length > 0) {
|
||||
for (const reaction of data.reactions) {
|
||||
const id = reaction.emoji.id ? `${reaction.emoji.name}:${reaction.emoji.id}` : reaction.emoji.name;
|
||||
this.reactions.set(id, new MessageReaction(this, data.emoji, data.count, data.me));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,13 +55,17 @@ class ReactionEmoji {
|
||||
* Represents a reaction to a message
|
||||
*/
|
||||
class MessageReaction {
|
||||
constructor(message, emoji, count) {
|
||||
constructor(message, emoji, count, me) {
|
||||
/**
|
||||
* The message that this reaction refers to
|
||||
* @type {Message}
|
||||
*/
|
||||
this.message = message;
|
||||
|
||||
/**
|
||||
* Whether the client has given this reaction
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.me = me;
|
||||
this._emoji = new ReactionEmoji(this, emoji.name, emoji.id);
|
||||
/**
|
||||
* The number of people that have given the same reaction.
|
||||
|
||||
Reference in New Issue
Block a user