0

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);
    });
  • Does this answer your question? [None of my discord.js guildmember events are emitting, my user caches are basically empty, and my functions are timing out?](https://stackoverflow.com/questions/64559390/none-of-my-discord-js-guildmember-events-are-emitting-my-user-caches-are-basica) – Lauren Yim Dec 03 '20 at 09:53

2 Answers2

1

Make sure that in the server, there is a channel called 'log'

Just to debug, add a console.log to the return clause

wyvern
  • 116
  • 1
  • 7
0

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
})
Jytesh
  • 815
  • 4
  • 15