Discord.js 机器人有没有办法检查提及?

Posted

技术标签:

【中文标题】Discord.js 机器人有没有办法检查提及?【英文标题】:Discord.js bot is there a way to check mention? 【发布时间】:2021-01-08 22:43:09 【问题描述】:

Attached below is a part of my code. What it does is that if I type "pain.throw @user" it will throw out an embed and some text. However, if I don't mention a user, my code doesn't work. Is there a way someone can show me to let the bot spit out a message and say "You have to mention someone for this to work" or something. Thank you. Any help is appreciated.

【问题讨论】:

请勿提供代码图片。 【参考方案1】:

只需添加一个

if (!usernamegedUser) return message.channel.send("Try again, except mention someone");

const usernamegedUser = message.mentions.users.first();

【讨论】:

以上是关于Discord.js 机器人有没有办法检查提及?的主要内容,如果未能解决你的问题,请参考以下文章

无法让 Discord.js 在命令中提及用户

(discord.js) 如何提及对机器人消息做出反应的用户?

我正在尝试制作 discord.js 头像命令,但提及部分无法正常工作

Discord.js 如何使用机器人提及和设置前缀作为前缀

如何检查用户是不是具有特定角色 discord.js v12? [复制]

如何从提及 discord.js 添加角色