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
JavaScript
x
13
13
1
const personHugged = message.mentions.users.first();
2
3
if(personHugged){
4
let hugEmbed = new Discord.MessageEmbed()
5
.setTitle(`${message.author} hugged ${personHugged.username} :heart:`)
6
.setImage(images[Math. floor(Math. random()*images. length)])
7
.setTimestamp()
8
message.channel.send(hugEmbed);
9
}
10
else{
11
message.channel.send(`Sorry ${message.author} that user is not in this server!`);
12
}
13
I really hope you guys can help me out!
Advertisement
Answer
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
)
JavaScript
1
7
1
let hugEmbed = new MessageEmbed()
2
.setTitle(`Woo, that's a hug :heart:`)
3
.setDescription(`${message.author} hugged ${personHugged} :heart:`)
4
.setImage(images[Math.floor(Math.random() * images.length)])
5
.setTimestamp();
6
message.channel.send(hugEmbed);
7