【问题标题】:Discord.js Interaction await messages cannot get message objectsDiscord.js 交互等待消息无法获取消息对象
【发布时间】:2022-01-21 13:09:35
【问题描述】:

一旦用户在不和谐频道中创建交互,我想在该频道中收听新的传入消息。这是我得到的代码

if (interaction.customId.startsWith('TRIGGER')) {
  let filter = (m) => m.author.id === interaction.author.id;
  interaction.channel
    .send(`Are you sure to delete all data? \`YES\` / \`NO\``)
    .then(() => {
      interaction.channel
        .awaitMessages(filter, {
          max: 1,
          time: 30000,
          errors: ['time'],
        })
        .then((message) => {
          message = message.first();
          if (
            message.content.toUpperCase() == 'YES' ||
            message.content.toUpperCase() == 'Y'
          ) {
            message.channel.send(`Deleted`);
          } else if (
            message.content.toUpperCase() == 'NO' ||
            message.content.toUpperCase() == 'N'
          ) {
            message.channel.send(`Terminated`);
          } else {
            message.channel.send(`Terminated: Invalid Response`);
          }
        })
        .catch((collected) => {
          interaction.channel.send('Timeout');
        });
    });
}

但是我没有得到消息对象。好像没有消息发送

我该如何解决这个问题?

【问题讨论】:

    标签: javascript discord discord.js


    【解决方案1】:

    您的问题很可能在于您的过滤器,因为没有任何交互具有 author 属性。考虑将过滤器更改为以下内容:

    let filter = m => m.author.id === interaction.user.id;
    

    【讨论】:

      猜你喜欢
      • 2022-07-17
      • 1970-01-01
      • 2020-07-02
      • 2021-10-17
      • 1970-01-01
      • 2020-12-11
      • 2021-07-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多