at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js:11:14)
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```
#"config" is not defined
79 messages · Page 1 of 1 (latest)
• 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.
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds], partials: [Partials.Channel] });
const config = require('./config.json');
config();
client.on('ready', () => {
console.log(`${client.user.tag} is ready to go!`);
})
client.login(config.TOKEN);```
well 2 things-
configis a json file, not a function- make sure your file is saved
it is saved
here's really what your main file should look like according to the guide
the discord.js guide?
send
have you never seen the djs guide before? im curious
still dont work
v12 yea
instead of saying "it doesnt work" please be more specific. it doesnt help me
Require stack:
- C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js:2:19)
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) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\Users\\csj25\\OneDrive\\Desktop\\discordbot\\src\\index.js' ]```
you have a .json file, not config.js
oh nvm
ok now
Require stack:
- C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js:2:19)
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) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\Users\\csj25\\OneDrive\\Desktop\\discordbot\\src\\index.js' ]
}
Node.js v18.16.1```
either the file doesn't exist or its the wrong file path
do i move it in my source folder?
you can put it wherever you want, but the file path needs to be adjusted accordingly
soo const { TOKEN } = require('src/.config.json'); ?
not quite. that's not how file pathing works
- File paths explained in detail: learn more
.refers to the current directory..refers to the parent directory- Node path module: learn more
dont know what that is just say
you dont know what a file path is?
i think you should take a step back, look at the links here about proper file path structures and then continue because it's clear you need to refresh your memory on this
nah ill just remove it out of the source folder
there would never be new development, bug fixes and improvements to the library so yes we needed to. plus there are a ton of things in v12 that will cause errors and cannot be fixed due to discord's deprecated api that v12 uses
still the same error
Require stack:
- C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\src\index.js:2:19)
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) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\Users\\csj25\\OneDrive\\Desktop\\discordbot\\src\\index.js' ]
}
fix your file path
my answer is the same

thats what it is
okk? 
please read the suggestions i have given you. i cannot repeat myself anymore
took it out of the src folder and
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\index.js:6:1)
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```
^
okk? thats what you showed me lmao this isnt support 
which is?
at Object.<anonymous> (C:\Users\csj25\OneDrive\Desktop\discordbot\index.js:5:1)
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
show me your updated code
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const { TOKEN } = require('./config.json');
const client = new Client({ intents: [GatewayIntentBits.Guilds], partials: [Partials.Channel] });
config();
client.on('ready', () => {
console.log(`${client.user.tag} is ready to go!`);
})
client.login(TOKEN);```
you said config(); defined it yesterday
that was for your .env file which you don't seem to be using today
two different things
cus neither work
it does if you read the guide properly
instead of getting so defensive over it
im trying to help as best as i can
but you're not putting in enough effort for this
i highly suggest you make your main file look like this, but its just a suggestion so im not forcing you
this is mainly for best practice and should be used
jus nvm bro discord.py is easier
use whatever library you want and that is your opinion
not an opinion everyone says it
do you still need help or no?
im good lil bro
Creating Your Bot: Creating the main file