When does it occur?

The authentication token for your Discord bot was not found or appears to be invalid. This might happen if the token is regenerated, revoked, or the bot’s access to the server is restricted.

discord.js
Error [TOKEN_INVALID]: An invalid token was provided.
discord.py
LoginFailure: Improper token has been passed.

Why does it occur?

You will encounter this error when your application attempts to authenticate with the Discord API using an invalid or outdated bot token.

How to fix

Ensure that the token provided when creating the Discord.js client is accurate and up-to-date. If you suspect the token might be invalid, regenerate it on the Discord Developer Portal.

Regenerate the Token

If you have confirmed that the current token is invalid or compromised, generate a new one on the Discord Developer Portal.

Update the Token in Your Code

If you are using a .env file to store the token, make sure to update the file with the new token.

Generally, the token is stored in .env or config,json files. If you are using a different method to store the token, update the code accordingly.

Keep the library up to date

Ensure you are using the latest version of your library. Developers regularly update the library to fix bugs and address compatibility issues.

Update discord.js
npm install discord.js@latest
# or update in your package.json
Update discord.py
pip install discord.py
# or update in your requirements.txt

Reboot Your Application

After implementing the changes, restart your application to apply the updates. This ensures that the new token and any code modifications take effect.

If you continue to experience any issues, please don’t hesitate to contact our support team.