R
R
rodgi2020-02-26 00:15:36
JavaScript
rodgi, 2020-02-26 00:15:36

How to count the number of reactions per message?

I am doing the `coinflip` command. It is necessary that when you click on the reaction (in my case, the "OK" reaction), the bot gives the result of the coin. How to count the number of reactions per message?

module.exports.run = async (bot, message, args) => {

        let temp = [
        "Орел",
        "Решка"
    ];
    var result = temp[Math.floor(Math.random() * 2)]
    let coinembed = new Discord.RichEmbed()
        .setColor("#ff9900")
        .setDescription("Орел/решка!");
        message.channel.send(coinembed)
        message.react("ОК")
    
        await message.react('ОК');
            
        message.channel.send(result)
    };

Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
2
2CHEVSKII, 2020-02-26
@rodgi

Everything is in the official documentation .
To be more precise, take a message from message.channel.send(coinembed) and save it to a variable. You catch the messageReaction(Add/Remove) event when it happens - check the number of reactions (see link) on the message that you have stored in a variable.

I
ince, 2020-02-26
@ince

You call an instance of this function and make a counter through a closure

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question