javascript 使用 discord.js 收集对消息做出反应的用户

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46877312/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 07:00:37  来源:igfitidea点击:

Collecting users who reacted to a message using discord.js

javascriptnode.jsdiscorddiscord.js

提问by Maze

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

但它返回未定义。如果我使用“reaction.emoji”它会返回

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.

我正在努力争取这users: Collection { '370300235030986752' => [Object] },部分。提前致谢。

回答by Jake Weary

According to the docsit is just reaction.users:

根据文档,它只是reaction.users

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