問題描述
如何讓不和諧的機器人提及用戶? (How to make a discord bot mention a user?)
我現在正在製作一個不和諧的機器人,並想發出一個 poke 命令。用戶可以戳另一個成員。我知道如何提及作者,但我似乎無法提及用戶。示例:'!poke [作者給出的用戶]'。
如何讓我的機器人提及該用戶?
參考解法
方法 1:
You can use user.toString()
. For example:
bot.on("message", (message) => {
if(message.content.startsWith("poke")){
let userToMention = message.mentions.users.first();
message.channel.send("Mention: "+userToMention.toString());
}
});
If you write !poke @user
, the bot will reply with Mention: @user
.
(by CrossScript、Androz2091)