Home > Back-end >  Discord Api Valid intents must be provided for the Client but the code dosent work
Discord Api Valid intents must be provided for the Client but the code dosent work

Time:02-26

I set up the

const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

for my discord.js bot.

But now I just get the error message:

Uncaught c:\Users\niko\Documents\bot\receptionist\index.js:8

The line 8 in my index.js is this:

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

CodePudding user response:

remove the first line of the code which states:

  
 const Discord = require('discord.js')

and also delete the third line of the code which follows :

const client= new Discord.Client()

because you're declaring the client with the intents below after declaring the prefix. And also delete

const bot = client

CodePudding user response:



const {Client, Intents, MessageEmbed, Presence, Collection, Interaction}= require ('discord.js')
const client = new Client({intents:[Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]})

CodePudding user response:

this is my code this is not my complet code my code

  • Related