【发布时间】: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