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