Reputation: 107
I made a poll command in discord.js
, but I'm not sure how I can get the amount of people who reacted to a specific emoji. This is my code:
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);
Upvotes: 3
Views: 4624
Reputation: 8402
You can use the Message.reactions.cache
, which will return a collection of every MessageReaction
on that message. From there, you can use Collection#get()
to fetch your preferred reaction, and use the MessageReaction#count
to see how many people have reacted to it.
poll.reactions.cache.get('👍').count;
Upvotes: 8