简体   繁体   中英

How to mention username in bot message

I'm trying to have the user tagged instead of the ID mentioned (I've tried ${user.username} ) but it still doesn't actually mention the said user that the command runs on

Currently the command is $cake " User tag " but the bot won't physically mention them instead just write either their username or include there discriminator at the end.

So the code is

      recentUsers.push(message.author.id);
  setTimeout(() => {
    recentUsers.splice(recentUsers.indexOf(message.author.id), 1);
  }, COOLDOWN * 60 * 60 * 1000);

  message.channel.send({
    embed: {
      color: Cuckbot.colors.GREEN,
      description: `🍰 You have given one cake to ${user.id} 🍰`

If you try to send it like this (instead of user.id , just user ) :

description: `🍰 You have given one cake to ${user} 🍰`

It will convert the user to a String, and that conversion (with DiscordJS) makes it mentionable.
I'm not sure if it will actually mention the user (with the notification) but it will definitely make it clickable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM