javascript - 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.
堆栈跟踪中的任何地方都没有引用我的代码......
有谁知道发生了什么?我花了一个小时搜索并尝试调试它。
解决方案
结果发现它是 discord API 或 discord.js 的一个错误。通过更改完全不相关的代码行来修复。不要尝试使用 client.guilds.filter(...) 引用您的公会,这会导致各种问题,只能通过踢掉您的机器人并让他重新加入服务器来解决
推荐阅读
- godot - 线渲染有时不会检测到相交以及如何在循环时使其更宽容
- instagram - 2021年如何通过用户名获取INSTAGRAM图片 - Ruby on Rails
- javascript - 在新创建的输入中自动完成
- java - 如何在 Antlr4 Maven 插件中为组合语法配置 Java 生成的代码(无静态类,无最终方法)?
- c# - 使用 Task.WhenAll 和最大并行度实现并行任务调用时,如何管理锁?
- php - 显示 Woocommerce 属性值描述而不是值名称
- matlab - 图像处理实时瞌睡司机检测matlab
- javascript - 在粘贴大于特定高度的内容后,Quill 在基于 webkit 的浏览器(如 chrome)上滚动到顶部
- c# - 无需输入即可发送发件箱消息
- c# - 在 Graphql 中如何进行内部连接