错误在FLAGS discord.js最后版本nodejs

yqkkidmi  于 2023-08-04  发布在  Node.js
关注(0)|答案(1)|浏览(93)

我的代码很好,一切都很好,但我在discord.js最后一个版本上遇到了一个错误
错误:

const bot = new Discord.Client({ intents: [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES] });
                                                          ^
TypeError: Cannot read properties of undefined (reading 'FLAGS')
    at Object.<anonymous> (C:\Users\SasYT\Documents\DiscordBOTS\GDPS\bot.py:3:60)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47

字符串
我的代码:

const { Client, GatewayIntentBits } = require('discord.js')
const client = new Client({
    intents: [ [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES] });

bot.once('ready', () => {
  console.log('Bot is ready!');
});

mtb9vblg

mtb9vblg1#

在discord.js v14中,需要使用GatewayIntentBits

const { GatewayIntentBits, Client } = require("discord.js");
const client = new Client({
    intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages]
});

client.once('ready', () => {
  console.log('Bot is ready!');
});

字符串

相关问题