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

141
Vistas
'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 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