DiscordAPIError:缺少权限 - 机器人崩溃而不是给出错误消息

Posted

技术标签:

【中文标题】DiscordAPIError:缺少权限 - 机器人崩溃而不是给出错误消息【英文标题】:DiscordAPIError: Missing Permissions - Bot crashes instead of giving error message 【发布时间】:2021-07-26 02:52:37 【问题描述】:

我的机器人会发送一条嵌入消息,每次您单击反应时都会更改页面,一些服务器拒绝授予机器人“管理消息”权限,这会导致机器人崩溃,我希望机器人回复而是每次有人做出反应时都会出现错误消息,或者至少不会崩溃。

错误:

1.

DiscordAPIError: Missing Permissions
    at RequestHandler.execute (----\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
    at processTicksAndRejections (node:internal/process/task_queues:93:5) 
  method: 'delete',
  path: 
  code: 50013,
  httpStatus: 403

2.

(node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode).

【问题讨论】:

看看指南Missing Permissions。 【参考方案1】:

尝试在您的消息之后放置一个.catch((error) => ) 块,如下所示:message.channel.send(embed).catch((error) => console.log("error");) 希望能帮上忙 ShadowLp174

【讨论】:

以上是关于DiscordAPIError:缺少权限 - 机器人崩溃而不是给出错误消息的主要内容,如果未能解决你的问题,请参考以下文章

DiscordAPIError:缺少权限

机器人没有分配角色。我收到错误缺少权限

不和谐机器人的NodeJS错误:UnhandledPromiseRejectionWarning:DiscordAPIError:无法发送空消息

不断收到 DiscordAPIError:在 Discord.js 中的音乐机器人上使用 reconlx 的分页执行队列命令时出现未知交互

如何修复 DiscordAPIError:未知成员?

如何隐藏 DiscordAPIError (discord.js) (node.js)