【问题标题】:How do i make a discord bot reply to my command in a certain way我如何让不和谐的机器人以某种方式回复我的命令
【发布时间】:2021-08-03 05:27:12
【问题描述】:

我尝试以我在互联网上找到的各种方式编写条件语句。但是,机器人似乎没有识别我的客户 ID。我究竟做错了什么? 代码:

  if(msg.author === '<@8421258276382****>')
{
        const yorepLKB = yoRepliesKB[Math.floor(Math.random() * yoRepliesKB.length)];
        msg.reply(yorepLKB);
}

这里,引号内的id是我的discord id。

【问题讨论】:

  • 您能提供更多信息吗?代码示例/sn-ps、截图、错误等

标签: node.js discord discord.js


【解决方案1】:

message#author 返回一个 User 类,它不等于 &lt;@ID&gt;。 (尽管如果您在 message 中发送 User 类,Discord.JS 会将其解析为提及。)

你可以像这样检查User的ID:

if (msg.author.id === "123456789012345678")
{
   // Code
}

【讨论】:

    猜你喜欢
    • 2021-11-15
    • 2021-03-31
    • 2021-03-05
    • 2020-11-18
    • 2022-11-11
    • 1970-01-01
    • 2021-08-13
    • 2020-05-10
    • 2021-03-28
    相关资源
    最近更新 更多