Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 760
Maze Avatar asked Oct 22 '17 17:10

Maze


People also ask

How do I get a list of people that reacted to Discord?

Access a channel and head to the chat with messages you wish to check. Select a message and long-press on a reaction. This will open a new page that will reveal the people who have interacted with the text and their reactions.

How do you see what you've reacted to on Discord?

In the search bar add has:reaction so you can quickly find messages that have been reacted to.

How do you mention someone and message Discord in Javascript?

Discord uses a special syntax to embed mentions in a message. For user mentions, it is the user's ID with <@ at the start and > at the end, like this: <@86890631690977280> . If they have a nickname, there will also be a ! after the @ .


1 Answers

According to the docs it is just reaction.users:

client.on('messageReactionAdd', (reaction, user) => {
    if(reaction.emoji.name === "✅") {
        console.log(reaction.users);
    }
});
like image 132
Jake Weary Avatar answered Sep 20 '22 04:09

Jake Weary