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

150
Visualizações
'guildMemberAdd' add undefined using event handler Discord.js v12

So this is my first question on here. I am working on my Discord.js v12 bot and I recently updated it to have command_handlers & event_handlers. Most of the commands work fine but I am having a issue with the 'guildMemberAdd' event. I have searched for awhile for different fixes and the best fix I have found so far is from this stackoverflow post: guildmemberadd-event-handler-issues Which helped me out with the fixing the event handler but now I am getting a

TypeError: Cannot read property 'add' or undefined.

Below is my event_handler.js & my guildMemberAdd.js files

const fs = require('fs');

module.exports = (client, Discord) =>{
    const load_dir = (dir) =>{
        const event_files = fs.readdirSync(`./events/${dir}`).filter(file => file.endsWith('.js'));

        for(const file of event_files){
            const event = require(`../events/${dir}/${file}`);
            // const event_name = file.split('.')[0]; //This might be wrong.
            if(event.once) {
                client.once(event.name, event.execute(null, Discord, client));
            } else {
                client.on(event.name, event.execute(null, Discord, client));
            }
        }
    }

    ['client', 'guild'].forEach(e => load_dir(e));
}

module.exports = {
    name: 'guildMemberAdd',
    once: false,
    execute(Discord, client, member) {
        const roleDeckSwab = '630197242548060173';
        member.roles.add(roleDeckSwab);
    }
}

I have attempted to reorganize arguments thinking it was something to do with that but so far that hasn't helped either.

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