shawn
shawn

Reputation: 42

Welcome Message - TypeError: Cannot read property 'user' of undefined

I Am Trying To Make A Welcome Message With My Discord.js Bot I Keep Getting user is not defined while trying to get the bot to mention the new user

client.on('guildMemberAdd', async (message, member) => {

const welcomechannel = db.fetch(`welcomechannel_${message.guild.id}`)
// When new user joins, wait a few minutes, and if they haven't managed to get a role yet, DM them
client.channels.cache.get(welcomechannel).send(`New member joined: ${member.user.tag}`);
});

Upvotes: 2

Views: 789

Answers (1)

Syntle
Syntle

Reputation: 5174

the guildMemberAdd event does not have a message parameter

client.on('guildMemberAdd', async (member) => {
const welcomechannel = db.fetch(`welcomechannel_${member.guild.id}`)
client.channels.cache.get(welcomechannel).send(`New member joined: ${member.user.tag}`);
});

Upvotes: 2

Related Questions