DiscordAPIError:未知消息

时间:2018-05-25 21:07:04

标签: javascript node.js discord discord.js

我使用discord.js和commando制作了一个冻结命令,它为用户提供了一个角色,让他们不会说话和聊天。似乎每次我运行它,它都会抛出一个错误:

(node:7352) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message

我还没能找到它是什么,但也许我只是一个小块。

代码:

async run(message, { user }) {
  message.delete()

  const member = message.guild.member(user);

  if (!message.member.hasPermission("MUTE_MEMBERS")) return message.say("Sorry, but you do not have the Mute Members Permission! If you beleive this is a error, contact an owner.");

  if (!user) return message.say(`Cannot find user!`)

  if (member.hasPermission("MUTE_MEMBERS")) return message.say("The user you are trying to freeze is either the same, or higher role than you.");

  let muterole = message.guild.roles.find(`name`, "Frozen");

  if (member.roles.has(muterole)) return message.say(`${user.username} is already frozen!`);

  if (!muterole) {
    try {
      muterole = await message.guild.createRole({
        name: "Frozen",
        color: "#000000",
        permissions: []
      })
      message.guild.channels.forEach(async(channel, id) => {
        await channel.overwritePermissions(muterole, {
          SEND_MESSAGES: false,
          ADD_REACTIONS: false,
          SPEAK: false
        });
      });
    } catch (e) {
      console.log(e.stack);
    }

    await (member.addRole(muterole.id))
    message.say(`**${user.username} has been frozen! To unfreeze them, use the unfreeze command!**`)
    message.delete(5000)
  }
}

任何帮助将不胜感激!感谢。

1 个答案:

答案 0 :(得分:1)

我认为这是因为您在第一行中删除了[{'name': 'Atucha', 'location': (-34.0, -59.167), 'active_reactors': 1}, {'name': 'Embalse', 'location': (-32.2333, -64.4333), 'active_reactors': 1}, {'name': 'Armenia', 'location': (40.167, 44.133), 'active_reactors': 1}, {'name': 'Br', 'location': (51.217, 5.083), 'active_reactors': 1}, {'name': 'Doel', 'location': (51.333, 4.25), 'active_reactors': 4}, {'name': 'Tihange', 'location': (50.517, 5.283), 'active_reactors': 3}] 的邮件,但最后您使用message.delete()再次删除邮件。 其余代码运行正常,因为即使您删除了邮件,它仍保存在message.delete(5000)变量中,但当您尝试再次删除时,API无法找到它。尝试删除其中一个message