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 toolkit2y 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-OP2y ago
Well, its probably not a djs problem, but im still hoping on your answers my boys
grass
grass2y ago
config.json isnt valid json
-NAVODKA-
-NAVODKA-OP2y ago
Wdym by that ? What should i do ?
grass
grass2y ago
your json file is not valid json
-NAVODKA-
-NAVODKA-OP2y ago
I have this json file i created it
-NAVODKA-
-NAVODKA-OP2y ago
grass
grass2y ago
okay good for you it does exist doesnt mean its valid json
-NAVODKA-
-NAVODKA-OP2y ago
Okay, i can remove this thing from the code Wait
grass
grass2y ago
if your car door is stuck, do you take it off? or do you get it fixed
-NAVODKA-
-NAVODKA-OP2y ago
nah so how do i fix it ;-;
grass
grass2y ago
show your config.json
-NAVODKA-
-NAVODKA-OP2y 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
grass2y ago
what please dont ping me for support
-NAVODKA-
-NAVODKA-OP2y ago
A Im sorry
grass
grass2y ago
also, delete those messages and reset your token
-NAVODKA-
-NAVODKA-OP2y ago
got it
d.js docs
d.js docs2y 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
Dozz2y ago
Don't send your bots token 💀
-NAVODKA-
-NAVODKA-OP2y ago
my bad regenerated it
Dozz
Dozz2y ago
K good I think your token is bad / did not set it up correctly
-NAVODKA-
-NAVODKA-OP2y 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 docs2y ago
discord Gateway: Gateway Intents read more
Want results from more Discord servers?
Add your server