Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

132
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda