CrossScript
CrossScript

Reputation: 5

How to make a discord bot mention a user?

I am now making a discord bot and want to make a poke command. The user can poke another member. I know how to mention the author but I cannot seem to mention the user. EXAMPLE: '!poke [user given by the author]'.

How do I make my bot mention that user?

Upvotes: 0

Views: 860

Answers (1)

Androz2091
Androz2091

Reputation: 3005

You can use user.toString(). For example:

bot.on("message", (message) => {

    if(message.content.startsWith("poke")){
        let userToMention = message.mentions.users.first();
        message.channel.send("Mention: "+userToMention.toString());
    }

});

If you write !poke @user, the bot will reply with Mention: @user.

Upvotes: 1

Related Questions