An error when i try node main.js, im absolutely new at javascript and i wanna try to do my small bot

PS C:\Users\User\Desktop\Discord Bot> node main.js node:internal/modules/cjs/loader:1327 throw err; ^ SyntaxError: C:\Users\User\Desktop\Discord Bot\config.json: Unexpected token : in JSON at position 7 at parse (<anonymous>) at Module.load (node:internal/modules/cjs/loader:1119:32) at Module.require (node:internal/modules/cjs/loader:1143:19) at require (node:internal/modules/cjs/helpers:110:18) at Object.<anonymous> (C:\Users\User\Desktop\Discord Bot\main.js:2:17) at Module._compile (node:internal/modules/cjs/loader:1256:14) at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) at Module.load (node:internal/modules/cjs/loader:1119:32) Node.js v18.16.1 (Here is the error) const { Client, Intents} = require('discord.js'); const {token} = require('./config.json'); const client = new Clent({intents: [Intents.FLAGS.guilds]}); client.once('ready', ()=>{ console.log('Ready!'); }) client.login(token); (Here is my code)
23 Replies
d.js toolkit
d.js toolkit•12mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Post the full error stack trace, not just the top part! - Show your code! - Explain what exactly your issue is. - Not a discord.js issue? Check out #useful-servers.
-NAVODKA-
-NAVODKA-•12mo ago
Well, its probably not a djs problem, but im still hoping on your answers my boys
grass
grass•12mo ago
config.json isnt valid json
-NAVODKA-
-NAVODKA-•12mo ago
Wdym by that ? What should i do ?
grass
grass•12mo ago
your json file is not valid json
-NAVODKA-
-NAVODKA-•12mo ago
I have this json file i created it
-NAVODKA-
-NAVODKA-•12mo ago
grass
grass•12mo ago
okay good for you it does exist doesnt mean its valid json
-NAVODKA-
-NAVODKA-•12mo ago
Okay, i can remove this thing from the code Wait
grass
grass•12mo ago
if your car door is stuck, do you take it off? or do you get it fixed
-NAVODKA-
-NAVODKA-•12mo ago
nah so how do i fix it ;-;
grass
grass•12mo ago
show your config.json
-NAVODKA-
-NAVODKA-•12mo ago
One symbol is red Okay, i fixed this one But still the same error @)7(&3!;$?7;72&:!;&,84$4;Umm, sir, are you here ?
grass
grass•12mo ago
what please dont ping me for support
-NAVODKA-
-NAVODKA-•12mo ago
A Im sorry
grass
grass•12mo ago
also, delete those messages and reset your token
-NAVODKA-
-NAVODKA-•12mo ago
got it
d.js docs
d.js docs•12mo ago
- Visit the Discord developer application dashboard and select the corresponding application - Click on "Bot" on the left side - Click the "Reset Token" button and (if enabled) enter your 2FA code on the popup
Dozz
Dozz•12mo ago
Don't send your bots token 💀
-NAVODKA-
-NAVODKA-•12mo ago
my bad regenerated it
Dozz
Dozz•12mo ago
K good I think your token is bad / did not set it up correctly
-NAVODKA-
-NAVODKA-•12mo ago
atleast after few "fixes" i have another error C:\Users\User\Desktop\Discord Bot\main.js:3 const client = new Client({intents: [Intents.FLAGS.guilds]}); ^ TypeError: Cannot read properties of undefined (reading 'FLAGS') at Object.<anonymous> (C:\Users\User\Desktop\Discord Bot\main.js:3:46) at Module._compile (node:internal/modules/cjs/loader:1256:14) at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) at Module.load (node:internal/modules/cjs/loader:1119:32) at Module._load (node:internal/modules/cjs/loader:960:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47 Node.js v18.16.1
d.js docs
d.js docs•12mo ago
discord Gateway: Gateway Intents read more