when I start my discord bot, I get an unhandled promise rejection token error but the bot token is stored in the env file where I call it correctly in the index file and there are no spaces in the env file so I don't understand how this is happening. The bot works fine when I run it locally but its only when I run it on repl that there is a problem. Has anyone experienced this problem before?
UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
at CommandoClient.login (/home/runner/Beat-Bot/node_modules/discord.js/src/client/Client.js:205:52)
Upon further investigation, when I try to console.log the env variables so console.log(process.env.VARIABLE) they all return undefined.
.env file. Inside, put:
so if my token was
abc it becomes:
can't post an answer, but comment is fine.
so with js bot, you can't create .env file anymore, use secrets tab and create a variable called TOKEN and paste the token in value field. save and run your repl.
You are probably using the client id!! Go to the portal > bot > then get the token, its really long. Mark as answered if this helps.