Kin*_*ire 15 node.js discord.js
我在 v13+ 上使用 Discord.js Bot 时遇到问题。我收到[DISALLOWED_INTENTS]错误。我怎样才能解决这个问题?谢谢。
(node:16060) UnhandledPromiseRejectionWarning: Error [DISALLOWED_INTENTS]: Privileged intent provided is not enabled or whitelisted. at WebSocketManager.createShards (C:\Users\schne\Desktop\Zeltux_v1.5.2\node_modules\discord.js\src\client\websocket\WebSocketManager.js:260:15)
[05:24:04] (node:16060) 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)
[05:24:04] (node:16060) [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.
Run Code Online (Sandbox Code Playgroud)
Jak*_*kye 36
正如错误所示,[DISALLOWED_INTENTS]: Privileged intent provided is not enabled or whitelisted您可能正在使用尚未启用的意图。
网关意图在 v12 中引入到库中,允许您选择您的机器人将接收哪些事件。意图是discord.js 客户端将有条件订阅的一组预定义事件。例如,省略DIRECT_MESSAGE_TYPING意图将阻止 discord.js 客户端从直接消息接收任何打字事件。
您必须转到Discord Developer Portal,选择您的应用程序,转到该Bot部分,然后启用所有意图。(或者你正在使用的那些。)
