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

202
Visualizações
Discord.js: ban user that reacted to a message with emoji

I am working on a discord bot who is supposed to ban members that reacted to a specific message with a specific emote. The file I created for the messageReactionAdd event currently contains the following code:

module.exports = {
    name: 'messageReactionAdd',
    execute(client, reaction, user) {
        const channel = client.channels.cache.find(channel => channel.name === 'test');
        let message = 874736592542105640;
        let emotes = ['kannathinking', '🍎'];
        let roleID = (reaction.emoji.name == emotes[0] ? '874730080486686730' : '874729987310235738')

        if (message == reaction.message.id && (emotes[0] == reaction.emoji.name || emotes[1] == reaction.emoji.name)) {
        user.ban();
        channel.send(`${user} was banned`);
        }
    }
}

However this code doesn't work and throws me the following error:

user.ban() is not a function

After doing some research I found out that the ba command only works on GuildMember objects. Unfortunately those aren't created when messageReactionAdd is called. Does anyone have an idea how to work around it?

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

0

You don't have to get the GuildMember object, you can just ban the user by id from GuildMemberManager which can be found from the reaction object via reaction.message.guild.members

So instead of using user.ban() you can use

reaction.message.guild.members.ban(user.id)
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