IntentsBitField is not a constructor

I'm following this part of the guide: https://discordjs.guide/popular-topics/intents.html#enabling-intents Below is the code that I'm using to create an instance of the Client with the right intents:
// Require the necessary discord.js classes
const { Client, IntentsBitField } = require("discord.js");
const intents = new IntentsBitField();

intents.add(
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.GuildMessageReactions,
IntentsBitField.Flags.DirectMessages,
IntentsBitField.Flags.DirectMessageReactions
);

// Create a new client instance with the correct intents. See:
// https://discordjs.guide/popular-topics/intents.html#error-disallowed-intents
const client = new Client({ intents });
// Require the necessary discord.js classes
const { Client, IntentsBitField } = require("discord.js");
const intents = new IntentsBitField();

intents.add(
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.GuildMessageReactions,
IntentsBitField.Flags.DirectMessages,
IntentsBitField.Flags.DirectMessageReactions
);

// Create a new client instance with the correct intents. See:
// https://discordjs.guide/popular-topics/intents.html#error-disallowed-intents
const client = new Client({ intents });
When I run the code, I get the following error stack:
{
"stack": "TypeError: IntentsBitField is not a constructor
at Object.create (E:\\GitHub\\MrClockwork-v4-indev\\discord\\client.js:7:18)
at initializeClient (E:\\GitHub\\MrClockwork-v4-indev\\discord\\index.js:17:34)
at Object.exports.startDiscordIntegration (E:\\GitHub\\MrClockwork-v4-indev\\discord\\index.js:7:26)
at _initializeComponents (E:\\GitHub\\MrClockwork-v4-indev\\app_bot.js:67:23)",
"message": "IntentsBitField is not a constructor"
}
{
"stack": "TypeError: IntentsBitField is not a constructor
at Object.create (E:\\GitHub\\MrClockwork-v4-indev\\discord\\client.js:7:18)
at initializeClient (E:\\GitHub\\MrClockwork-v4-indev\\discord\\index.js:17:34)
at Object.exports.startDiscordIntegration (E:\\GitHub\\MrClockwork-v4-indev\\discord\\index.js:7:26)
at _initializeComponents (E:\\GitHub\\MrClockwork-v4-indev\\app_bot.js:67:23)",
"message": "IntentsBitField is not a constructor"
}
I'm running Discord v13.12. I'm not sure what the problem is.
2 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Drithyl
Drithyl2y ago
Sorry, I went ahead and updated to 14 instead; didn't realize there was a version difference.