Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
RPS Command with reactions not working - discord.js

I am making a discord bot in discord.js v13 and I need to make a rock, paper, scissors command and I made the following code: (I left out some parts because I couldn't post it, mainly embeds like NoResponse messages, so if something doesn't have a value, the name probably suggests what it's supposed to be!

Code:

const discord = require('discord.js');

You lost! :confused:")
    .setColor(colors.COLOR);
const cancelled = new discord.MessageEmbed()
    .setDescription(":x: Cancelled! You failed to respond in time!")
    .setColor(colors.COLOR);
module.exports = {
    name: "rps",
    aliases: [],
    async execute(client, message, args) {

        message.channel.send({ embeds: [noResponse] }).then(msg => {
            msg.react("🪨");
            msg.react("✂️");
            msg.react("📰");

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

            const choices = ['🪨', '✂️', '📰'];
            const me = choices[Math.floor(Math.random() * choices.length)];
            msg.awaitReactions({ filter, max: 1, time: 20000, error: ['time'] }).then(
                async (collected) => {
                    const reaction = collected.first();
                    const result = new Discord.MessageEmbed()
                        .setTitle("Results", `${reaction.emoji.name}`)
                        .addField("Your choice:", `${me}`)
                        .setColor(colors.COLOR)
                    msg.edit(result);

                    if ((me === "🪨" && reaction.emoji.name === "✂️") ||
                        (me === "✂️" && reaction.emoji.name === "📰") ||
                        (me === "📰" && reaction.emoji.name === "🪨")) {
                        message.channel.send({ embeds: [youLost] });
                    } else if (me === reaction.emoji.name) {
                        return message.channel.send({ embeds: [resultTie] });
                    } else {
                        return message.channel.send({ embeds: [youWin] });
                    }
                })
                .catch(collected => {
                    message.channel.send({ embeds: [cancelled] });
                });
        });
    }
}

However, when I run the bot it sends the message, and adds the reactions, but then when the time runs out, it gives the canceled embed (it timed out) even though I reacted to the message.

I tried fixing it in multiple ways but I don't know what it is. Is it something that changed in discord.js v13?

I don't know how to fix this. Does somebody know?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!