【问题标题】:Discordjs TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the ClientDiscordjs TypeError [CLIENT_MISSING_INTENTS]:必须为客户端提供有效的意图
【发布时间】:2022-06-19 02:57:41
【问题描述】:

我正在为 ddiscord 制作一个机器人,但我无法解决此错误: TypeError [CLIENT_MISSING_INTENTS]:必须为客户端提供有效的意图。

const { Client, Intents } = require('discord.js');

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

const config = require('./config.json')
const dotenv = require('dotenv')
dotenv.config()

const privateMessage = require('./private-message'); 
const test = require('./test.js')

const mySecret = process.env['TOKEN'];





client.on('ready', () => {
  console.log(`${client.user.tag} has logged in.`);
});

这是完整的错误:

D:\user\Bots\dadobot2801\a\node_modules\discord.js\src\client\Client.js:548
      throw new TypeError('CLIENT_MISSING_INTENTS');
      ^

TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.
    at Client._validateOptions (D:\user\Bots\dadobot2801\a\node_modules\discord.js\src\client\Client.js:548:13)
    at new Client (D:\user\Bots\dadobot2801\a\node_modules\discord.js\src\client\Client.js:76:10)
    at Object.<anonymous> (D:\user\Bots\dadobot2801\a\test.js:4:16)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (D:\user\Bots\dadobot2801\a\index.js:10:14) {
  [Symbol(code)]: 'CLIENT_MISSING_INTENTS'
}

有什么想法吗?

【问题讨论】:

标签: discord.js


【解决方案1】:

试试这个。由于 discord.js 的新更新如 ^13.0 版,您必须指定客户端意图:

const { Client, Intents } = require('discord.js');

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

你是怎么做的

【讨论】:

  • 这与 OP 当前的代码有何不同?如果原来的不行,你为什么认为它会起作用?
  • 我试过了,但它给了我同样的错误
  • 检查this out
【解决方案2】:

我之前遇到过这个问题,所以我知道如何解决它。如上图所示,您需要启用这 3 个意图。

【讨论】:

    【解决方案3】:

    它不允许我添加评论,所以我想我必须去这里... 你有没有找到答案?我的机器人将它们放在应用程序面板上,并且我的代码设置了两者

    const client = new Client({
        partials: ["MESSAGE", "CHANNEL", "REACTION"],
        intents: 32767,
    });
    

    const client = new Client({
        partials: ["MESSAGE", "CHANNEL", "REACTION"],
        intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS,],
    });
    Neither of them work I still get missing intents.
    

    【讨论】:

      猜你喜欢
      • 2021-10-14
      • 2021-10-17
      • 2021-12-02
      • 2021-10-12
      • 1970-01-01
      • 2021-05-23
      • 2020-07-15
      • 2017-08-26
      • 2022-07-20
      相关资源
      最近更新 更多