所以我正在制作一个 Discord 机器人,并且我已经被这个问题困扰了很长一段时间。我正在尝试检查提到的用户是否是机器人。我用过
message.mentions.members.first();
检查存储在变量profileMentionned
let profileMentionned = message.mentions.members.first();
作为提到的配置文件参数。但是当我尝试放入
profileMentionned.bot
在 if 语句中,它永远不会输出 boolean
值,它不会测试用户是否是机器人,而只会作为我设置的 var 的默认值出现
这是“未定义”
。
这是我的来源:
case "profile":
var isAdmin = "undefined";
let profileMentionned = message.mentions.members.first();
if (!profileMentionned) return message.channel.send("Error message about mentionning a user")
if (profileMentionned.hasPermission("MANAGE_MESSAGES"))
{
isAdmin = "Admin boi";
} else {
isAdmin = "Member pleb";
//Now here's the problem part
if (profileMentionned.bot) isAdmin = "Bot";
//I also tried with "if (profileMentionned === true) isAdmin = "Bot";"
break;
谢谢您的回答! <3:)
最佳答案
用户有机器人标志,而成员(member)则没有。
您需要执行profileMentionned.user.bot
。
查看文档here .
关于javascript - 检查提到的个人资料是否是机器人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50109779/