[英]How do I make a “+mention” command in Discord.js
How do I create a discord command for my bot that will mention someone? 如何为我的机器人创建一个会提及某人的discord命令?
For ex: 例如:
Sample input: +mention Gamer222
输入样例:
+mention Gamer222
Sample output: @Gamer222#6478
样本输出:
@Gamer222#6478
I have tried multiple things like: 我已经尝试了多种方法,例如:
if(command === "mention") {
const sayMessage = args.join(" ");
message.channel.send(`${sayMessage}`);
}
But it isn't working. 但这不起作用。
Answer previously posted on the question: 先前在此问题上发布的答案:
if (command === "mention") {
const sayMessage = args.join(" ");
message.channel.send(client.users.find('username', sayMessage).toString());
}
Or this : 或这个 :
if (command == "mention") {
const sayMessage = message.mentions.users.first()
if(!sayMessage) return message.channel.send("Please mention a user.")
message.channel.send(`${sayMessage}`)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.