Im using Discord.js V13 and when i try to run the bot i get this error everytime.
Main File:
const { Discord, Intents } = require('discord.js');
const client = new Discord.Client({
partials: ["CHANNEL","MESSAGE","REACTION"],
intents: [Intents.ALL]
});
The error:
const client = new Discord.Client({
^
TypeError: Cannot read properties of undefined (reading 'Client')
The solution here is that i can`t deconstruct the library from itself, and my mistake is that i needed to put only the intents that my bot needs.
My solution:
const Discord = require('discord.js');
const client = new Discord.Client({
partials: ["CHANNEL","MESSAGE","REACTION"],
intents: [
Discord.Intents.FLAGS.GUILDS, // <--line 5 here
Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.GUILD_INVITES,
Discord.Intents.FLAGS.GUILD_MEMBERS,
Discord.Intents.FLAGS.GUILD_PRESENCES
]
});
Advertisement
Answer
You cannot deconstruct the library from itself.
Either deconstruct the client:
const { Client, Intents } = require('discord.js');
const client = new Client(...);
// ...
Or utilitize the library entirely:
const Discord = require('discord.js');
const client = new Discord.Client(...);
// ...