问题
I am looking to create a command in order to tag certain users.
This is what I have tried:
var players = [
"@RYAN#9602"
]
switch(args[0].toLowerCase()){
case "play":
message.channel.send(players.join('\n'));
break;
}
However, it just sends a message into the text channel without actually tagging the user.
In summmary, I am looking to be able to tag a user through a discord.js bot.
Any help would be greatly appreciated, thanks!
回答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 + ">");
});
来源:https://stackoverflow.com/questions/47622930/how-to-tag-users