An invalid token was provided.

if (!token || typeof token !== 'string') throw new Error('TOKEN_INVALID');
^

Error [TOKEN_INVALID]: An invalid token was provided.
at Client.login (E:\MartozAi\node_modules\discord.js\src\client\Client.js:237:52)
at Object.<anonymous> (E:\MartozAi\index.js:77:8)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
[Symbol(code)]: 'TOKEN_INVALID'
}
if (!token || typeof token !== 'string') throw new Error('TOKEN_INVALID');
^

Error [TOKEN_INVALID]: An invalid token was provided.
at Client.login (E:\MartozAi\node_modules\discord.js\src\client\Client.js:237:52)
at Object.<anonymous> (E:\MartozAi\index.js:77:8)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
[Symbol(code)]: 'TOKEN_INVALID'
}
I have already recreated the token several times, changed everything and everything exactly gives an error
22 Replies
d.js toolkit
d.js toolkit8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Kinect3000
Kinect30008mo ago
Ur not providing a token into client.login
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Kinect3000
Kinect30008mo ago
Or it’s null/undefined (or anything besides a non-empty string)
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Martoz
MartozOP8mo ago
client.login(process.env.TokenBot);
client.login(process.env.TokenBot);
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Martoz
MartozOP8mo ago
require('dotenv').config();
require('dotenv').config();
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Martoz
MartozOP8mo ago
Yes, I tried inserting the token into clietn.login(), but it didn't help
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Martoz
MartozOP8mo ago
is it convenient to view it like this? do you know how to fix it?
Svitkona
Svitkona8mo ago
can you log the token before you try to login
Martoz
MartozOP8mo ago
?
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Martoz
MartozOP8mo ago
console.log(process.env.TokenBot)
client.login(process.env.TokenBot);
console.log(process.env.TokenBot)
client.login(process.env.TokenBot);
it doesn't output anything
Svitkona
Svitkona8mo ago
then that means you didn't configure your environment correctly
Martoz
MartozOP8mo ago
But I didn't touch the code, reinstalled Windows yesterday, saved the code, did everything, and here comes this error
Svitkona
Svitkona8mo ago
do you have a .env file
Martoz
MartozOP8mo ago
ye
Svitkona
Svitkona8mo ago
change your code to this: require('dotenv').config({ debug: true }); see if it logs anything
clfr
clfr8mo ago
try to change tkn variable name
Want results from more Discord servers?
Add your server