【问题标题】:How can I check if a message is a reply and check the replied message content? (discord.js)如何检查消息是否为回复并查看回复的消息内容? (discord.js)
【发布时间】:2022-01-24 17:59:13
【问题描述】:

这是我的目标: 检查包含命令的消息是否是对其他消息的回复 如果是,则检查用户回复的消息的内容。 例如: 留言一:您好!你好吗? 消息 2(对消息 1 的回复):!command

现在我希望我的机器人检查消息 2 是否是回复,如果是,请检查消息 1 的 console.log 内容

我正在使用 discord.js v13。

【问题讨论】:

    标签: javascript node.js ecmascript-6 discord.js


    【解决方案1】:

    您可以使用<Message>.reference 来查看回复。

    例如,检查msg2是否是对msg1的回复并记录msg1的内容:

    if (msg2.type === 'REPLY' && msg2.reference.messageId === msg1.id)
      console.log(msg1.content);
    

    如果您没有msg1 并且需要查找,可以使用<Message>.fetchReference 获取回复。

    if (msg2.type === 'REPLY') {
      const msg1 = await msg2.fetchReference();
      console.log(msg1.content);
    }
    

    【讨论】:

      猜你喜欢
      • 2021-07-01
      • 1970-01-01
      • 2018-03-20
      • 1970-01-01
      • 2018-07-21
      • 2021-04-18
      • 2021-10-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多