I am currently working on a welcome embed functionality for my bot.
But I am having trouble mentioning a user.
I tried every method I found but they all seem to be for previous versions of discord.js
Here is the code I used
bot.on('guildMemberAdd', member => {
member.guild.channels.get('channelID').send({
title: 'We got a new user',
description: 'Welcome <mention>'
}]
});
});
CodePudding user response:
Firstly, you can mention, but not ping (send a notification) in embeds. Secondly, you have to put it in the embeds
property
member.guild.channels.get('channelID').send({
embeds: [{
title: "We got a new user",
description: `Welcome ${member.toString()}`
}]
})
You can use the member.toString()
method to get the mention. Another way is <@${member.id}>
. Note that embeds
is an array
CodePudding user response:
const embed = new MessageEmbed()
.setTitle('We got a new user')
.setDescription(`Welcome <@${member.id}>`)
bot.on('guildMemberAdd', member => {
member.guild.channels.cache.get('channelID').send({
embeds: [embed]
});
});