【问题标题】:TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client [duplicate]TypeError [CLIENT_MISSING_INTENTS]:必须为客户端提供有效的意图[重复]
【发布时间】:2021-10-14 01:06:47
【问题描述】:

帮助 ;-;

PS D:\Files\Berinon\utils> node .
D:\Files\Berinon\node_modules\discord.js\src\client\Client.js:544
      throw new TypeError('CLIENT_MISSING_INTENTS');
      ^

TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.
    at Client._validateOptions (D:\Files\Berinon\node_modules\discord.js\src\client\Client.js:544:13)
    at new Client (D:\Files\Berinon\node_modules\discord.js\src\client\Client.js:73:10)
    at Object.<anonymous> (D:\Files\Berinon\utils\index.js:3: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 Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
    at node:internal/main/run_main_module:17:47 {
  [Symbol(code)]: 'CLIENT_MISSING_INTENTS'
}

这是我将 Discord.client 更改为 Discord.Client 后遇到的错误。我只知道 .client 被定义为 any。不是像 .Client 这样的构造函数。 如果有人想知道代码,这里就是。

const Discord = require('discord.js');

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

const mongoose = require('mongoose')


require('dotenv').config();

client.queue = new Map();
client.commands = new Discord.Collection();
client.events = new Discord.Collection();

['command_handler', 'event_handler'].forEach(handler =>{
    require(`./handlers/${handler}`)(client, Discord)
})

mongoose.connect(process.env.MONGODB_SRV, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    userFindAndModify: false,
    })
    .then(() => {
        console.log('Succesfully connected to MongoDB')
    })
    .catch((err) => {
        console.log(err)
    })

client.login(process.env.TOKEN)

【问题讨论】:

    标签: javascript discord bots


    【解决方案1】:

    我也遇到了同样的问题,显然 discord.js 已在另一篇文章中更新,这很有帮助 the solution is here

    【讨论】:

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