'How could I mention a user in an embed?
I'm currently having an issue where I'm unable to ping people in embeds. I've searched up solutions online, but none of them are working. Here's my code, thanks.
else if (command === 'post') {
if (!message.member) return;
const messageContent = args.slice(1).join(' ');
if (!messageContent) return await message.channel.send("Invalid syntax, please include full detail, including what you need done, payment, time etc.");
await message.channel.send("Post sent for approval.");
const hiringEmbed = new Discord.MessageEmbed()
.setColor(embedColor)
.setTitle('Hiring post.')
.setAuthor({name : message.member.user.username, iconURL : message.member.user.displayAvatarURL()})
.setDescription(messageContent)
.setFooter({text : `Post by <@${message.member.user.id}>`}) // This is the line that wont work
.setTimestamp()
await client.channels.cache.find(channel => channel.id === '937027971137548378').send({embeds : [hiringEmbed]});
}
Solution 1:[1]
To ping someone you need to add the user to the content of the message you send channel.send({content:'<@${id}>', embeds: [hiringEmbed]
Solution 2:[2]
You cannot ping a member in an embed but rather only mention them. So, you need to ping them in the regular content of the message instead of the embed.
await client.channels.cache.find(channel => channel.id === '937027971137548378').send({content: `${message.member.user.id}`, embeds : [hiringEmbed]});
In the footer you can use their username instead if you want to mention who used the command.
Solution 3:[3]
.setFooter({text : `Post by ${message.author.tag}`})
or
.setFooter(`Post by ${message.author.tag}`)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Simon Stnn |
| Solution 2 | leftomash |
| Solution 3 | Shunya |
