TypeError: Cannot read properties of undefined (reading 'FLAGS')

Hello, I got an error with the flags. Could someone help?
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_CHANNELS] });
client.login('token replaced');

async function createChannelsCommand(interaction) {
await interaction.deferReply();

const category = await interaction.guild.channels.create('important', {
type: 'category'
});

await interaction.guild.channels.create('rules', {
type: 'text',
parent: category.id
});

await interaction.guild.channels.create('announcements', {
type: 'text',
parent: category.id
});

await interaction.guild.channels.create('welcome', {
type: 'text',
parent: category.id
});

await interaction.editReply('Done!');
}
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_CHANNELS] });
client.login('token replaced');

async function createChannelsCommand(interaction) {
await interaction.deferReply();

const category = await interaction.guild.channels.create('important', {
type: 'category'
});

await interaction.guild.channels.create('rules', {
type: 'text',
parent: category.id
});

await interaction.guild.channels.create('announcements', {
type: 'text',
parent: category.id
});

await interaction.guild.channels.create('welcome', {
type: 'text',
parent: category.id
});

await interaction.editReply('Done!');
}
42 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Cgx
CgxOP2y ago
Full Error: TypeError: Cannot read properties of undefined (reading 'FLAGS') at Object.<anonymous> (C:\Users\user\ServerMaster\bot.js:2:47) at Module._compile (node:internal/modules/cjs/loader:1254:14) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47 Node.js Version: 18.15.0 Discord.js Version: 14.8.0 Ok, done now theres ReferenceError: Client is not defined at Object.<anonymous> (C:\Users\user\ServerMaster\bot.js:2:16) at Module._compile (node:internal/modules/cjs/loader:1254:14) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47
Cgx
CgxOP2y ago
got this now
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
i just relized atm
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
now the bitfield is invalid...
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined. at IntentsBitField.resolve (C:\Users\user\ServerMaster\node_modules\discord.js\src\util\BitField.js:170:11) at C:\Users\user\ServerMaster\node_modules\discord.js\src\util\BitField.js:165:54 at Array.map (<anonymous>) at IntentsBitField.resolve (C:\Users\user\ServerMaster\node_modules\discord.js\src\util\BitField.js:165:40) at new BitField (C:\Users\user\ServerMaster\node_modules\discord.js\src\util\BitField.js:33:38) at new IntentsBitField (C:\Users\user\ServerMaster\node_modules\discord.js\src\util\IntentsBitField.js:9:1) at Client._validateOptions (C:\Users\user\ServerMaster\node_modules\discord.js\src\client\Client.js:491:25) at new Client (C:\Users\user\ServerMaster\node_modules\discord.js\src\client\Client.js:78:10) at Object.<anonymous> (C:\Users\user\ServerMaster\bot.js:2:16) at Module._compile (node:internal/modules/cjs/loader:1254:14) { code: 'BitFieldInvalid' oh but the s is in the code so
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
Ok
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
yep
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
hmm i could try
Cgx
CgxOP2y ago
you mean like this?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
Discord is not definied
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
yup.
Cgx
CgxOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
No, but its still the same error then
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
cant click.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
No
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
yes
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
It's still there.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
yes for now
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
ok worked ...
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
Ok. So the bot should work with application commands, but it isnt listed thre.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Cgx
CgxOP2y ago
hmm ok, well thank you anyways, sinc the bot is running.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server