Check whether the running process has the token
TokenInvalid in discord.js and LoginFailure in discord.py can come from a missing environment variable or a token Discord has rejected. Compare the exact variable name in the login call with the name in the deployment’s Variables. Bothosting’s starters use BOT_TOKEN.
Temporarily log only whether the value is present. Start the process through the deployment dashboard so the check runs with the same environment as the bot. Remove the check when you finish.
console.log("BOT_TOKEN is set", Boolean(process.env.BOT_TOKEN?.trim()));import os
print("BOT_TOKEN is set", bool(os.getenv("BOT_TOKEN", "").strip()))Update the deployment with the current bot token
- Open the Discord Developer Portal and select the application installed in your test server. In Bot, confirm you’re using its bot token. The application ID, public key and OAuth client secret serve other purposes.
- If the token was reset, exposed or lost, reset it for that application. Last time’s token becomes invalid. Update any other authorized copy that needs the new value.
- Gesetzt
BOT_TOKENin Variables as the raw token. Remove surrounding quotes, spaces and anyBotprefix. Save and restart. Keep the token out of the repository and Console.
See Discord’s app setup und den deployment secrets guide.
Verify login and a Discord reply
Look for the ready event in Console and send /ping to the test app. If login succeeds but registration fails, check the slash command guide. If the gateway closes with 4014, the next step is to fix the requested intents.