Skip to content Skip to sidebar Skip to footer

How To Tag Users Using Discord.js?

I am looking to create a command in order to tag certain users automatically using their username eg. '@RYAN#9602' whenever a switch statement case is executed. Currently the probl

Solution 1:

You have two options.

You can either use the toString method on the User object, or form the mention yourself using the user's ID.

Here's an example using toString:

client.on("message", => {
    const channel = message.channel;
    channel.send(message.author.toString());
});

And here's an example using the ID

client.on("message", => {
    const channel = message.channel;
    channel.send("<@" + message.author.id + ">");
});

Solution 2:

Try using the toString method.

client.on("message", => {
    const channel = message.channel;
    channel.send(message.author.toString());
});

Post a Comment for "How To Tag Users Using Discord.js?"