I have a events handler that runs through a file called “events” that I found on the discord.js website. It appears as so, taking files from the event folder and calling them if they occur:
// creates an array of files from the commands file
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const event = require(`./events/${file}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
}
else {
client.on(event.name, (...args) => event.execute(...args));
}
}
An example of one of the events that works is one that is called when a channel is created:
module.exports = {
name: 'channelCreate',
execute(channel) {
console.log(`${channel.name} was created`);
console.log(channel.id);
},
};
However, when I try calling the addGuildMember event, which should occur when a member joins, it simply doesn’t work. Nothing shows up in the console and it doesn’t recognize a person has joined.
module.exports = {
name: 'guildMemberAdd',
execute(member) {
console.log('member joined');
console.log(member);
},
};
What am I doing wrong? I tried looking if guildMemberAdd was deprecated, but apparently it’s still used, has anybody successfully added this event with an event handler?