【发布时间】:2021-11-09 02:03:51
【问题描述】:
所以我最近在将我的机器人从 discord.js V12 更新到 V13 时遇到了这个错误。我知道我将 discord.js 更新到了 V13,因为它在我的 package.json 中。我不知道为什么这不起作用。我什至添加了所有不和谐的意图。
index.js 代码
const { Collection, MessageEmbed, Intents} = require("discord.js");
const token = process.env['TOKEN']
const server = require('./server.js');
const fs = require("fs")
const MongoClient = require('./utils/MongoClient');
const myIntents = new Intents();
myIntents.add(Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_BANS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS, Intents.FLAGS.GUILD_INTEGRATIONS, Intents.FLAGS.GUILD_WEBHOOKS, Intents.FLAGS.GUILD_INVITES, Intents.FLAGS.GUILD_MESSAGE_TYPING, Intents.FLAGS.DIRECT_MESSAGE_REACTIONS, Intents.FLAGS.DIRECT_MESSAGE_TYPING, Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS);
const bot = new MongoClient({ intents: myIntents});
package.json 代码
{
"name": "switch",
"version": "2.0.0",
"description": "Switch is a all new bot for discord!",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"discord.js": "^13.1.0",
"express": "^4.17.1",
"fs": "^0.0.1-security",
"mongoose": "^6.0.5"
},
"devDependencies": {
"node": "^16.6.1"
}
}
错误
/home/runner/switch-beta-test/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 MongoClient._validateOptions (/home/runner/switch-beta-test/node_modules/discord.js/src/client/Client.js:544:13)
at new Client (/home/runner/switch-beta-test/node_modules/discord.js/src/client/Client.js:73:10)
at new MongoClient (/home/runner/switch-beta-test/utils/MongoClient.js:12:9)
at Object.<anonymous> (/home/runner/switch-beta-test/index.js:13:13)
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 Missing Intent Error on discord.js
-
MongoClient是您的扩展 discord.js 客户端还是您的 mongodb 的连接脚本? -
我的
MongoClient处理 mongodb 的所有功能并连接到数据库,在 discord.js V12 中,我能够直接从我的 index.js 使用意图。当我看到有什么问题时,我将我的意图转移到我的MongoClient文件以修复我的错误。
标签: discord.js