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

146
Visualizações
How to exclude the bot's reaction in the reaction collector

I had some old code, which I made during V12 of discord.js, which was working correctly. The code failed on me recently upon changing most of the required things to change (things that had changed for v13) and I made a more simplified version to see what the issue was and it seems that the message was sent to the bot, instead of anyone who reacted to the message.

const { client, message } = require("discord.js")

module.exports = {
    name: "collect",
    description: "--",
    category: "info",

    async execute(message, args, client) {

        const newMsg = await message.channel.send("words")

        newMsg.react("✅")

        const filter = (reaction, user) => {
            return !user.bot
        };

        const collector = newMsg.createReactionCollector(filter, { time: 6000000 });

        collector.on('collect', (reaction, user) => {
            user.send("it worked")
        });

    }
}

This is the code, where I want the bot to create a message, create a reaction below and allow the user to react to it, so it can gain the user's id and send them a message.

However, once I run the code, It sends the message, creates the reaction, and throws back this error below;

DiscordAPIError: Cannot send messages to this user
    at RequestHandler.execute (E:\Github\Valorant-Curios-Tournaments\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (E:\Github\Valorant-Curios-Tournaments\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
    at async UserManager.createDM (E:\Github\Valorant-Curios-Tournaments\node_modules\discord.js\src\managers\UserManager.js:58:18)
    at async ClientUser.send (E:\Github\Valorant-Curios-Tournaments\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:162:18) {
  method: 'post',
  path: '/users/852994509628768298/channels',
  code: 50007,
  httpStatus: 400,
  requestData: { json: { recipient_id: '852994509628768298' }, files: [] }
}

The recipient's ID is the same as the bot's ID, so I assume that it is not filtering out the bot's ID with the filter;

const filter = (reaction, user) => {
    return !user.bot === message.author.id;
};

Any help would be appreciated, thank you.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Nevermind, I am really dumb

Filter is in the object.

const collector = newMsg.createReactionCollector(filter, { time: 6000000 });

to fix this, I just needed to make it

const collector = newMsg.createReactionCollector({filter, time: 6000000 });
about 4 years ago · Juan Pablo Isaza Relatório
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