Reputation: 3
I copied some code from the discord.js documentation for functionality, https://discord.js.org/#/docs/main/stable/examples/greeting Although I changed a few things I have triggered it yet no errors are being thrown and neither are any messages that should be sent. My code:
client.on('guildMemberAdd', member => {
const channel1 = member.guild.channels.cache.find(channel => channel.name === 'logs');
if (!channel1) return;
const welcomeembed = new Discord.MessageEmbed()
.setColor('#d18604')
.setTitle(`Welcome, ${member.displayName} to **Server • 2.0!**`)
.setDescription('**IP:** mc.hypixel.net', '**Rules:** #rules')
.setTimestamp()
.setFooter('Server Bot')
channel1.send(welcomeembed);
});
Upvotes: 0
Views: 302
Reputation: 825
Discord recently added privileged gateway intents, to receive member data and events you need to go and enable the Member intent in the Developer Portal. Your app should work fine after that. If you don't wish to do that you need to enable partials for the member class, but be wary you may receive incomplete data.
To enable partials
client = new Client({partials: 'MEMBER'})
client.on('guildMemberAdd', async (member) => {
//Since we may receive partial data
if(member.partial) await member.fetch() //Fetches the member and loads it to cache.
//Do your stuff here
})
Upvotes: 0
Reputation: 136
Make sure that in the server, there is a channel called 'log'
Just to debug, add a console.log to the return clause
Upvotes: 1