mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
Add reaction fetching of users
This commit is contained in:
@@ -108,6 +108,28 @@ class MessageReaction {
|
||||
const message = this.message;
|
||||
return message.client.rest.methods.removeMessageReaction(message.channel.id, message.id, this.emoji.identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all the users that gave this reaction. Resolves with a collection of users,
|
||||
* mapped by their IDs.
|
||||
* @returns {Promise<Collection<string, User>>}
|
||||
*/
|
||||
fetchUsers() {
|
||||
const message = this.message;
|
||||
return new Promise((resolve, reject) => {
|
||||
message.client.rest.methods.getMessageReactionUsers(message.channel.id, message.id, this.emoji.identifier)
|
||||
.then(users => {
|
||||
this.users = new Collection();
|
||||
for (const rawUser of users) {
|
||||
const user = this.message.client.dataManager.newUser(rawUser);
|
||||
this.users.set(user.id, user);
|
||||
}
|
||||
this.count = this.users.size;
|
||||
resolve(this.users);
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MessageReaction;
|
||||
|
||||
Reference in New Issue
Block a user