我如何修复CLIENT_MISSING_INTENTS错误(Discord.js)



我已经尝试了1天了,仍然无法解决这个错误。

误差

TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.

const { Client, Collection } = require("discord.js");
const { config } = require("dotenv");
const fs = require("fs");
const { Intents } = require('discord.js');
const client = new Client({
disableEveryone: true,
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_BANS, Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS, Intents.FLAGS.GUILD_INTEGRATIONS, Intents.FLAGS.GUILD_WEBHOOKS, Intents.FLAGS.GUILD_INVITES, Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_MESSAGE_TYPING, Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.DIRECT_MESSAGE_REACTIONS, Intents.FLAGS.DIRECT_MESSAGE_TYPING],
});

节点版本:16.6.1不和版本:"^ 13.0.1">是的,我已经启用了所有意图从discord.com/developers

clientOptions.disableMentions已被clientOptions.allowedMentions取代

似乎这是导致问题的原因,这应该可以工作。

const { Client, Collection, Intents } = require("discord.js")
const { config } = require("dotenv")
const fs = require("fs")

const client = new Client({
allowedMentions: { parse: ['users', 'roles'], repliedUser: true },
intents: [
Intents.FLAGS.GUILDS, 
Intents.FLAGS.GUILD_MEMBERS, 
Intents.FLAGS.GUILD_BANS, 
Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS, 
Intents.FLAGS.GUILD_INTEGRATIONS, 
Intents.FLAGS.GUILD_WEBHOOKS, 
Intents.FLAGS.GUILD_INVITES, 
Intents.FLAGS.GUILD_VOICE_STATES, 
Intents.FLAGS.GUILD_PRESENCES, 
Intents.FLAGS.GUILD_MESSAGES, 
Intents.FLAGS.GUILD_MESSAGE_REACTIONS, 
Intents.FLAGS.GUILD_MESSAGE_TYPING, 
Intents.FLAGS.DIRECT_MESSAGES, 
Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
Intents.FLAGS.DIRECT_MESSAGE_TYPING
]
})

注意:不建议使用all意图。只使用那些你真正需要的。这加快了连接时间,并且在API上更容易。

相关内容

  • 没有找到相关文章

最新更新