简体   繁体   English

我想列出对 Discord 做出反应的用户。 对于 Discord.js

[英]I want to list the users who have reacted to Discord. for Discord.js

I want to list the users who have reacted to Discord.我想列出对 Discord 做出反应的用户。

let MyChannel = client.channels.get('573534660852711426');
    MyChannel.fetchMessage('656352072806957066').then(themessage => {
    for (const reaction of themessage.reactions){
        for (let user of reaction.users){
            console.log(user);
        }
        console.log(reaction);
    }
});

This is my code, but it doesn't work.这是我的代码,但它不起作用。 Can you help me.你能帮助我吗。

Thank you.谢谢你。

You need to use Reaction.fetchUsers .您需要使用Reaction.fetchUsers Try something like that:尝试这样的事情:

let MyChannel = client.channels.get('573534660852711426');
    MyChannel.fetchMessage('656352072806957066').then(async themessage => {
    for (const reaction of themessage.reactions){
        for (let user of await reaction.fetchUsers(){
            console.log(user);
        }
        console.log(reaction);
    }
});

I edited reaction.users with await reaction.fetchUsers() and I added async because await must be used in an asynchronous function.我编辑reaction.usersawait reaction.fetchUsers()和我加入async因为await必须在异步函数一起使用。

The error I get when I run the code is as follows.我运行代码时得到的错误如下。

    at F:\js\index.js:41:37
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:23364) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:23364) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```

38 let MyChannel = bot.channels.get('648985076817985556');
39      MyChannel.fetchMessage('650431271436156969').then(async themessage => {
40          for (const reaction of themessage.reactions){
41              for (let user of await reaction.fetchUsers()){
42                  console.log(user);
43              }
44              console.log(reaction);
45          }
46      });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用discord.js收集对邮件作出反应的用户 - Collecting users who reacted to a message using discord.js Discord.js - 获取对消息做出反应的用户列表,并根据他们的反应为他们分配角色 - Discord.js - Get list of Users who reacted to a Message and assign them roles depending on their reaction Discord.JS | 显示具有特定角色的用户 - Discord.JS | Display Users who have a specific roles 获取在 Discord 中对带有特定表情符号的消息做出反应的用户对象列表 - Get list of objects of users who reacted to a message with certain emoji in Discord 在 discord.js 中创建使用相同命令的用户列表 - Create a list of users who use the same commands in discord.js 你如何创建一个反应收集器,它可以 output 做出反应的用户的名称并将它们保存在 discord.js 中? - How do you create a reaction collecter which can output the names of users who reacted and save them in discord.js? 获取第一个反应的用户 discord.js - get user that reacted first discord.js Discord.js v12 如何获取对特定消息做出反应的人的 ID? - Discord.js v12 How to get the id of a person who reacted on a specific message? Discord.js:如何让所有对带有特定表情符号的消息做出反应的用户,然后将用户列表设置为变量? - Discord.js: how do I get all the users who react to a message with a specific emoji, then set the list of users to a variable? 获取所有对消息做出反应的用户(discord.js) - Get all users who have added a reaction to a message (discord.js)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM