如何计算反应 Discord js

Far*_*lah 3 javascript node.js discord discord.js

我在 中做了一个投票命令discord.js,但我不确定如何获得对特定表情符号做出反应的人数。这是我的代码:

if (!args[1]) return message.channel.send('You need to ask a question.');
let pollq = args.join(' ');
let whoask = msg.author.username;

const poll = new D.MessageEmbed()
 .setTitle('New Poll')
 .setAuthor(
  'Cleansound',
  'https://yt3.ggpht.com/a/AATXAJxJ8Qab93CDlxO7tOg06Jifb1Z1-14j1Xj2nt3dNg=s100-c-k-c0xffffffff-no-rj-mo'
 )
 .setDescription(`${whoask} Baru Saja Membuat Pollin question baru`)
 .setDescription(`${pollq}`)
 .addField(`  `, 'Untuk Setuju')
 .addField(`  `, 'Untuk Tidak Setuju')
 .setTimestamp()
 .setFooter(
  'Cleansound Host',
  'https://yt3.ggpht.com/a/AATXAJxJ8Qab93CDlxO7tOg06Jifb1Z1-14j1Xj2nt3dNg=s100-c-k-c0xffffffff-no-rj-mo'
 );
await poll.react('');
await poll.react('');
msg.channel.send(poll);
Run Code Online (Sandbox Code Playgroud)

Lio*_*100 5

您可以使用Message.reactions.cache,它将返回MessageReaction该消息上每个的集合。从那里,您可以使用Collection#get()来获取您的首选反应,并使用MessageReaction#count来查看有多少人对此做出了反应。

poll.reactions.cache.get('').count;
Run Code Online (Sandbox Code Playgroud)