首页 > 解决方案 > Discord.js Unknown Guild 从用户删除所有角色时

问题描述

我正在尝试从用户中删除所有角色。这段代码昨天有效,但我今天上了,它不知何故坏了。

message.member.removeRoles(message.member.roles.filter(role => role.name!='Admin' && role.name!='@everyone'));

堆栈跟踪:

(node:27392) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Guild
at item.request.gen.end (C:\Users\nnova\Documents\Discord\Bots\repbot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:71:65)
at then (C:\Users\nnova\Documents\Discord\Bots\repbot\node_modules\snekfetch\src\index.js:215:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:27392) 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:27392) [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.

堆栈跟踪中的任何地方都没有引用我的代码......

有谁知道发生了什么?我花了一个小时搜索并尝试调试它。

标签: javascriptnode.jsdiscord.js

解决方案


结果发现它是 discord API 或 discord.js 的一个错误。通过更改完全不相关的代码行来修复。不要尝试使用 client.guilds.filter(...) 引用您的公会,这会导致各种问题,只能通过踢掉您的机器人并让他重新加入服务器来解决


推荐阅读