1

I'm trying to make a welcomer bot, it all works but for some reason, the user who joined's name is undefined. Here's the code:

client.on('guildMemberAdd', (joinMember) => {
    const joinChannel = client.channels.cache.find(channel => channel.id === '931712815637602331')
    let joinEmbed = {
        title : `Welcome to ${joinMember.guild.name}, @${joinMember.tag}`,
        color : embedColor
    }
    joinChannel.send({embeds : [joinEmbed]})
})
Zsolt Meszaros
  • 21,961
  • 19
  • 54
  • 57
Tom W
  • 59
  • 2
  • 9
  • 1
    Does this answer your question? [What is the difference between a User and a GuildMember in discord.js?](https://stackoverflow.com/questions/63979076/what-is-the-difference-between-a-user-and-a-guildmember-in-discord-js) – MrMythical Jan 16 '22 at 14:49

1 Answers1

2

joinMember is a GuildMember and it doesn't have a tag property. It does have a user property though and Users have tags, so you can use joinMember.user.tag:

client.on('guildMemberAdd', (joinMember) => {
  const joinChannel = client.channels.cache.get('931712815637602331');
  let joinEmbed = {
    title: `Welcome to ${joinMember.guild.name}, @${joinMember.user.tag}`,
    color: embedColor,
  };
  joinChannel.send({ embeds: [joinEmbed] });
});
Zsolt Meszaros
  • 21,961
  • 19
  • 54
  • 57