Im using Discord.js V13 and when i try to run the bot i get this error everytime.
Main File:
JavaScript
x
7
1
const { Discord, Intents } = require('discord.js');
2
3
const client = new Discord.Client({
4
partials: ["CHANNEL","MESSAGE","REACTION"],
5
intents: [Intents.ALL]
6
});
7
The error:
JavaScript
1
5
1
const client = new Discord.Client({
2
^
3
4
TypeError: Cannot read properties of undefined (reading 'Client')
5
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:
JavaScript
1
14
14
1
const Discord = require('discord.js');
2
3
const client = new Discord.Client({
4
partials: ["CHANNEL","MESSAGE","REACTION"],
5
intents: [
6
Discord.Intents.FLAGS.GUILDS, // <--line 5 here
7
Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
8
Discord.Intents.FLAGS.GUILD_MESSAGES,
9
Discord.Intents.FLAGS.GUILD_INVITES,
10
Discord.Intents.FLAGS.GUILD_MEMBERS,
11
Discord.Intents.FLAGS.GUILD_PRESENCES
12
]
13
});
14
Advertisement
Answer
You cannot deconstruct the library from itself.
Either deconstruct the client:
JavaScript
1
5
1
const { Client, Intents } = require('discord.js');
2
3
const client = new Client( );
4
// ...
5
Or utilitize the library entirely:
JavaScript
1
5
1
const Discord = require('discord.js');
2
3
const client = new Discord.Client( );
4
// ...
5