[TOKEN_INVALID]: An invalid token was provided [TOKEN_INVALID]: An invalid token was provided heroku heroku

[TOKEN_INVALID]: An invalid token was provided


I run into a similar problem, i encrypted the token so that i could store the encrypted token on heroku and decrypt it in the js to pass the actual token to the login method.The weird part is, if i write the token directly as string into the js file or i use heroku and store it directly there, then it works. But if i store the encrypted token in heroku and decrypt it (and yes it is correctly decrypted) and give the decrypted token to the login method then it does not work.I dunno if heroku make some weird stuff or discord.js doesnt support something i dont know...

So, what definitly works is:You insert the token (client secret) on herokus config vars (settings from your dyno), then you use process.env.BOT_TOKEN and pass it to your Discord.Client().login().I assume in your case its bot.login(process.env.BOT_TOKEN).

So for me it looks like the value i store in heruko and the value i send to discord must be the same...


You should enter a valid Discord bot token. You can obtain it by going to the Discord Developer Portal, then "Applications", select your bot, then go to "Bot" and click "Copy" under the token (it says click here to reveal).


Deploying app on heroku you have to change you client.login(token) to client.login(process.env.token) and add token to enter image description hereas token - key and value - token copied from discord developers portal, remember (important note!) letters has to be the same, I mean, if you use capitals in process.env.TOKEN, the config var has to be now TOKEN.