I have tried this which is a copy of existing code from another one of my bots that works but when i run it i get a error saying “Intents is not defined”
JavaScript
x
9
1
const client = new Discord.Client({
2
intents: [
3
Intents.FLAGS.GUILDS,
4
Intents.FLAGS.GUILD_MESSAGES,
5
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
6
Intents.FLAGS.GUILD_PRESENCES,
7
],
8
})
9
Error:
JavaScript
1
2
1
ReferenceError: Intents is not defined
2
Advertisement
Answer
Simply, you should define the Intents by doing this:
JavaScript
1
2
1
const { Client, Intents } = require('discord.js')
2
Edit: You dont need to use Discord
on discord.js v13 since its not needed, instead do it like this:
JavaScript
1
11
11
1
const { Client, Intents } = require('discord.js')
2
3
const client = new Client({
4
intents: [
5
Intents.FLAGS.GUILDS,
6
Intents.FLAGS.GUILD_MESSAGES,
7
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
8
Intents.FLAGS.GUILD_PRESENCES,
9
],
10
})
11