如何在另一条消息中提及一条消息的作者
How to mention the author of a message in another message
我正在使用 repl.it 开发一个机器人。我正在尝试制作一个命令,使机器人的行为如下:
Someone: !slap @someoneelse
Bot: @Someone slapped @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}`);
我正在使用 repl.it 开发一个机器人。我正在尝试制作一个命令,使机器人的行为如下:
Someone: !slap @someoneelse
Bot: @Someone slapped @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}`);