当前位置: 首页 > 知识库问答 >
问题:

不一致js缺少API权限[阻止终止节点进程]

仲孙思源
2023-03-14

我使用更改昵称做了一个挂机命令。每当机器人角色之上的用户使用此命令时。我得到以下错误(节点:169)

UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
    at RequestHandler.execute (/home/runner/MutedPinkBlogclient/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:169) 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). (rejection id: 1)
(node:169) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:169) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
    at RequestHandler.execute (/home/runner/MutedPinkBlogclient/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:169) 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). (rejection id: 2)

这将在稍后终止bots进程。这将进一步终止bots进程。是否有任何方法可以在不增加bot角色的情况下停止终止节点进程。这是我的命令代码

client.on('message', message => {
    if (message.content.includes('start-afk')) {
        message.member.setNickname(`AFK | ${message.author.username}`);
    }
    if (message.content.includes('end-afk')) {
        message.member.setNickname('');
    }
});

你能帮我吗?

共有1个答案

车辰龙
2023-03-14

不和谐不允许用户/机器人帐户更改某人的昵称,如果他们的角色高于你的机器人。

您所能做的就是捕获错误并向通道发送错误消息。

message.member.setNickname("Nickname").catch(error => message.channel.send("Couldn't update your nickname."));
 类似资料:
  • 今天,我调试了我的代码。但是,当我删除bot的权限时,出现了一个错误,“discordapi:缺少权限”。因此,我尝试了一些方法让bot检查它是否具有所需的权限。但是,当我尝试下面的代码时,我再次遇到一个错误:“UnhandledPromisejectionWarning:TypeError:无法读取未定义的属性'has'”

  • 问题内容: 强制保持Node.js进程运行的最佳方法是什么,即使其事件循环不为空,从而防止进程终止?我能想到的最好的解决方案是: 如果您将间隔时间保持足够长,它将使间隔运行,而不会引起过多干扰。 有更好的方法吗? 问题的长版 我有一个使用Edge.js来注册回调函数的Node.js脚本,以便可以从.NET中的DLL内部对其进行调用。每秒将调用此功能1次,发送一个应打印到控制台的简单序列号。 Edg

  • IBM Cloud上的Node Red dashboard在正常工作数月后于9月24日停止工作。节点红色仪表板节点最初已安装。该应用程序已经有一段时间没有更改了。到目前为止,在日志中找不到任何错误,也不确定要查找什么。

  • 我有以下规则: 所以基本上,我希望经过身份验证的用户能够读/写和集合。但当我创建一个用户并登录时,我会尝试写: 但我有一个错误: 不知道我做错了什么。任何帮助都将不胜感激——谢谢!

  • 我正在将redis发布/子系统转换为redis streams,这样我就可以为服务器发送的事件添加一些容错功能。 用传统的方式订阅很简单: 这会永久阻塞,并保持连接打开。在这种情况下,发布到redis将添加到您的日志中。 切换到流时,您使用而不是订阅,使用而不是发布,数据会有很大的不同。我正在努力解决的部分是阻塞。 发送消息时,我的“订阅”会接收第一条消息,但不会记录更多消息。

  • 我有一个在Node开发的API。JS,打字稿听localhost:3001我有一个Angular的前端应用程序,打字稿听localhost:4200 我正在尝试使用ngx-image-cropper上传图像文件,将其转换为base 64,从前端到API。 当补丁(更新)http请求发送到API时,我得到: 访问位于'http://localhost:3001/member/10'从原点'http: