【问题标题】:Select message by contents (discord.js)按内容选择消息(discord.js)
【发布时间】:2020-04-25 03:22:54
【问题描述】:

我需要在 discord.js 中选择以前发送的消息(来自机器人)

async () => {
    let fetched;
    fetched = await receivedMessage.channel.messages.startsWith("Please use the command:")
    fetched.delete()
}

我试过这个,但它似乎不起作用。
我正试图通过它的内容获取一条消息,然后删除它。

编辑:显然...“您可以使用带有限制选项的channel.messages.fetch 获取最后100 条消息,然后通过message.content.startsWith 过滤该集合,然后将其传递给channel.bulkDelete()
在我看来,这听起来像是这样做的方式 - 我会尽快尝试。

【问题讨论】:

    标签: javascript discord.js


    【解决方案1】:

    您不需要使用startsWith,只需使用message.author.bot 检查邮件是否由机器人发送。

    【讨论】:

      猜你喜欢
      • 2021-09-08
      • 2018-03-20
      • 2021-12-13
      • 2020-07-04
      • 2023-03-16
      • 1970-01-01
      • 2021-02-05
      • 2021-01-20
      • 2021-01-28
      相关资源
      最近更新 更多