Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

128
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda