【发布时间】:2020-06-06 14:43:09
【问题描述】:
所以在使用从频道中删除消息的.bulkDelete() 方法时,我收到此错误:
UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message
(node:11720) UnhandledPromiseRejectionWarning: 未处理的承诺 拒绝。此错误源于在异步内部抛出 没有 catch 块的函数,或者通过拒绝一个承诺 不使用 .catch() 处理。 (拒绝 ID:2)(节点:11720)[DEP0018] DeprecationWarning:不推荐使用未处理的承诺拒绝。在 未来,未处理的承诺拒绝将终止 具有非零退出代码的 Node.js 进程。
这是我的代码:
//delete the given amount of message + 1 for the sent message
let msgToDelete = parseInt(args[1]) + 1;
//filter messages too old and delete unfiltered messages
msg.channel.bulkDelete(msgToDelete, true)
.then(deleted => {
if (deleted.size <= 1) return;
msg.channel.send(`deleted ${args[1]} messages.`)
.then(m => m.delete(2500))
.catch(err => console.error);
}).catch(err => msg.channel.send(err));
提前致谢。
【问题讨论】:
标签: javascript node.js discord.js