我在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);
答案 0 :(得分:4)
您可以使用Message.reactions.cache
,它将返回该消息上每个MessageReaction
的集合。从那里,您可以使用Collection#get()
获取您喜欢的反应,并使用MessageReaction#count
查看有多少人对此反应。
poll.reactions.cache.get('?').count;