我正在使用repl.it来开发机器人。我正在尝试制作一个命令,使机器人的行为如下:
有人:@ slap @someoneelse Bot:@Someone打耳光@someoneelse
如何在不使用ID的情况下让机器人提及@someone
?多人将使用该命令,我不能只使用ID,因为它只适用于一个人。我没有找到任何帮助我的东西,文档也没有帮助。希望我能得到帮助!谢谢。
用户和成员有一个.toString()
方法,每次与字符串连接时自动调用:这意味着如果你键入"Hey " + message.author
你会得到"Hey @author"
这就是我要做的命令:
// First store the mentioned user (it will be undefiend if there's none, check that)
let mentionedUser = message.mentions.users.first();
// Reply by directly putting the User objects in the string:
message.channel.send(`${message.author} slapped ${mentionedUser}`);