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.