【发布时间】:2018-12-13 06:26:33
【问题描述】:
每当我尝试让新成员在我的机器人中扮演角色时,我的机器人都会遇到这个问题。代码如下:
bot.on('guildMemberAdd', member => {
member.addRole(member.guild.roles.find("name","User"));
});
这是我在新成员加入时遇到的错误:
(node:8308) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
at item.request.gen.end (C:\Users\REEE\Downloads\bot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:71:65)
at then (C:\Users\REEE\Downloads\bot\node_modules\snekfetch\src\index.js:215:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:8308) 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(). (rejection id: 2)
(node:8308) [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.
我已经为我的机器人授予了我的服务器的所有权限,但它仍然说它缺少权限。有什么建议吗?
【问题讨论】:
-
在我看来这是您的 API 没有适当权限的问题,而不是您的服务器中的机器人。为了正确调试,我们需要访问 node.js 部分代码,特别是 next_tick.js 第 188 行和 index.js 第 215 行
-
尝试将您的机器人角色设置为高于您要分配给用户的角色。
标签: javascript discord.js