Collecting users who reacted to a message using discord.js

这一生的挚爱 提交于 2019-12-21 20:42:58

问题


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.


回答1:


According to the docs it is just reaction.users:

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


来源:https://stackoverflow.com/questions/46877312/collecting-users-who-reacted-to-a-message-using-discord-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!