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 头像命令,但提及部分无法正常工作