0

I am trying to make an automatic system in which the bot has a timer and if it doesn't get enough reactions to the bot's message, it says one thing, but if the votes match, the other message is sent, I've got most of it working but I get an error with the "rpMessage.awaitReactions" line.

I've tried making the initial message a Const, a variable, a "let" and just message.awaitReactions

    if(cmd === `${prefix}rp`) {
        const rpMessage = message.channel.send("<@&608365714775998485> A Roleplay is being started by " + message.author + " React with :white_check_mark: to join / vote" + '\n' + "Just a few rules to remember:" + '\n \n' + "• Dont FRP as this will get you removed from the RP" + '\n' + "• Drive cars in your civ rank (You can find speeds if you click your name)" + '\n' + "• Listen to staff" + '\n' + "• Don't cop bait").then(rpvote => {
            rpvote.react('').then(() => rpvote.react(''));})

            const filter = (reaction, user) => {
                return ['', ''].includes(reaction.emoji.name) && user.id === message.author.id;
            };

            rpMessage.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] }) // This part isn't working 
                .then(collected => {
                    const reaction = collected.first();

                    if (reaction.emoji.name === '') {
                        message.reply('you reacted with a thumbs up.');
                    }
                    else {
                        message.reply('you reacted with a thumbs down.');
                    }
                })
                .catch(collected => {
                    console.log(`After a minute, only ${collected.size} out of 4 reacted.`);
                    message.reply('>rpfail.');
                });                
    }

It's supposed to get the reactions from the message, but it never is able to read the property of awaitReacions

1 Answers1

0

I am assuming the problem to be reusing code from stackoverflow question Discord.js message after receiving emoji reaction without updating the variables.

rpMessage.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] }) // This part isn't working 
                .then(collected => {
                    const reaction = collected.first();

                    if (reaction.emoji.name === '') {
                        rpMessage.reply('you reacted with a thumbs up.');
                    }
                    else {
                        rpMessage.reply('you reacted with a thumbs down.');
                    }
                })
                .catch(collected => {
                    console.log(`After a minute, only ${collected.size} out of 4 reacted.`);
                    rpMessage.reply('>rpfail.');
                });                
    }

The variable name is rPMessage for you and you have used message

Dhananjai Pai
  • 5,914
  • 1
  • 10
  • 25