【问题标题】:Check if mentioned profile is a bot检查提到的个人资料是否是机器人
【发布时间】:2018-10-11 02:18:01
【问题描述】:

所以我正在制作一个 Discord 机器人,但我已经被这个问题困扰了很长时间。我正在尝试检查提到的用户是否是机器人。我用过

message.mentions.members.first();

检查存储在变量profileMentionned中的提及

let profileMentionned = message.mentions.members.first();

作为提到的配置文件参数。但是当我试图把

profileMentionned.bot

在 if 语句中,它永远不会输出 boolean 值,它不会测试用户是否是机器人,只会作为我设置的 var 的默认值出现,即 "undefined"

这是我的来源:

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;

感谢您的回答!

【问题讨论】:

    标签: javascript node.js discord.js


    【解决方案1】:

    用户有机器人标志,但成员没有。
    你需要做profileMentionned.user.bot
    查看文档here

    【讨论】:

      猜你喜欢
      • 2015-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-07
      • 2019-04-24
      相关资源
      最近更新 更多