Collecting users who reacted to a message using discord.js

I’m trying to collect all users that have reacted to certain message.
My code

client.on('messageReactionAdd', (reaction, user) => {
    if(reaction.emoji.name === "✅") {
    console.log(reaction.emoji.users);
}

But it returns undefined. If I use “reaction.emoji” it returns

ReactionEmoji {
  reaction: 
   MessageReaction {
     message: 
      Message {
        channel: [Object],
        id: '371695165498458115',
        type: 'DEFAULT',
        content: 'bb',
        author: [Object],
        member: [Object],
        pinned: false,
        tts: false,
        nonce: '371695172469129216',
        system: false,
        embeds: [],
        attachments: Collection {},
        createdTimestamp: 1508689433217,
        editedTimestamp: null,
        reactions: [Object],
        mentions: [Object],
        webhookID: null,
        hit: null,
        _edits: [] },
     me: true,
     count: 1,
     users: Collection { '370300235030986752' => [Object] },
     _emoji: [Circular] },
  name: '✅',

I’m trying to get the users: Collection { '370300235030986752' => [Object] }, part. Thanks in advance.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

According to the docs it is just reaction.users:

client.on('messageReactionAdd', (reaction, user) => {
    if(reaction.emoji.name === "✅") {
        console.log(reaction.users);
    }
});

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply