'How to ping message author and user in Discord.js embed
i recently started with Discord.js and i am currently making a hug command. the command itself is working fine, but the problem i am facing is that i want the bot to ping the message author and the user that gets hugged. if i type in the command "a!hug @user" this is what i get: "<@1389615656215> hugged username", but i want it to show up like this: "@user hugged @user".
below is my code
const personHugged = message.mentions.users.first();
if(personHugged){
let hugEmbed = new Discord.MessageEmbed()
.setTitle(`${message.author} hugged ${personHugged.username} :heart:`)
.setImage(images[Math. floor(Math. random()*images. length)])
.setTimestamp()
message.channel.send(hugEmbed);
}
else{
message.channel.send(`Sorry ${message.author} that user is not in this server!`);
}
I really hope you guys can help me out!
Solution 1:[1]
You can't have mentions in embed titles. The only place you can add them is a field (using addField
, or addFields
) or the description (using setDescription
)
let hugEmbed = new MessageEmbed()
.setTitle(`Woo, that's a hug :heart:`)
.setDescription(`${message.author} hugged ${personHugged} :heart:`)
.setImage(images[Math.floor(Math.random() * images.length)])
.setTimestamp();
message.channel.send(hugEmbed);
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 | Zsolt Meszaros |