Prettier format pending files

This commit is contained in:
Builder.io 2025-11-09 22:40:19 +00:00
parent dd01fd30de
commit 2fa9f63763
2 changed files with 21 additions and 2 deletions

View file

@ -465,7 +465,9 @@ client.login(process.env.DISCORD_BOT_TOKEN).catch((error) => {
console.error(" 1. Token has been revoked by Discord"); console.error(" 1. Token has been revoked by Discord");
console.error(" 2. Token has expired"); console.error(" 2. Token has expired");
console.error(" 3. Token format is incorrect"); console.error(" 3. Token format is incorrect");
console.error("\n Solution: Get a new bot token from Discord Developer Portal"); console.error(
"\n Solution: Get a new bot token from Discord Developer Portal",
);
console.error(" https://discord.com/developers/applications"); console.error(" https://discord.com/developers/applications");
} }

View file

@ -1,12 +1,15 @@
# Discord Bot Token Invalid - Troubleshooting & Fix # Discord Bot Token Invalid - Troubleshooting & Fix
## Problem ## Problem
The Discord bot is failing to login with error: The Discord bot is failing to login with error:
``` ```
❌ Unhandled Promise Rejection: Error [TokenInvalid]: An invalid token was provided. ❌ Unhandled Promise Rejection: Error [TokenInvalid]: An invalid token was provided.
``` ```
This means the `DISCORD_BOT_TOKEN` environment variable is either: This means the `DISCORD_BOT_TOKEN` environment variable is either:
- Expired or revoked - Expired or revoked
- Invalid/malformed - Invalid/malformed
- For a bot that was deleted from Discord Developer Portal - For a bot that was deleted from Discord Developer Portal
@ -15,20 +18,24 @@ This means the `DISCORD_BOT_TOKEN` environment variable is either:
## Solution: Get a New Bot Token ## Solution: Get a New Bot Token
### Step 1: Go to Discord Developer Portal ### Step 1: Go to Discord Developer Portal
1. Visit: https://discord.com/developers/applications 1. Visit: https://discord.com/developers/applications
2. Sign in with your Discord account 2. Sign in with your Discord account
3. Click on the application named **"AeThex"** (or your app name) 3. Click on the application named **"AeThex"** (or your app name)
### Step 2: Get the Bot Token ### Step 2: Get the Bot Token
1. Click on the **"Bot"** tab on the left sidebar 1. Click on the **"Bot"** tab on the left sidebar
2. Under the "TOKEN" section, click **"Reset Token"** 2. Under the "TOKEN" section, click **"Reset Token"**
3. Click **"Yes, do it!"** to confirm (the old token will be revoked) 3. Click **"Yes, do it!"** to confirm (the old token will be revoked)
4. Click **"Copy"** to copy the new token 4. Click **"Copy"** to copy the new token
### Step 3: Update the Environment Variable ### Step 3: Update the Environment Variable
The new token looks like: `NTc4OTcxMjQ1NDU0OTUwNDIx.GxxxXX.xxxxxxxxxxxxxxxxxxxxxxxxxxxxx` The new token looks like: `NTc4OTcxMjQ1NDU0OTUwNDIx.GxxxXX.xxxxxxxxxxxxxxxxxxxxxxxxxxxxx`
**For Railway/Spaceship Deployment:** **For Railway/Spaceship Deployment:**
1. Go to your Railway/Spaceship dashboard 1. Go to your Railway/Spaceship dashboard
2. Go to environment variables 2. Go to environment variables
3. Update or add: `DISCORD_BOT_TOKEN=<new_token_here>` 3. Update or add: `DISCORD_BOT_TOKEN=<new_token_here>`
@ -36,6 +43,7 @@ The new token looks like: `NTc4OTcxMjQ1NDU0OTUwNDIx.GxxxXX.xxxxxxxxxxxxxxxxxxxxx
5. Redeploy the bot 5. Redeploy the bot
**For Local Development:** **For Local Development:**
1. Update `.env` file in `code/discord-bot/`: 1. Update `.env` file in `code/discord-bot/`:
``` ```
DISCORD_BOT_TOKEN=your_new_token_here DISCORD_BOT_TOKEN=your_new_token_here
@ -43,7 +51,9 @@ The new token looks like: `NTc4OTcxMjQ1NDU0OTUwNDIx.GxxxXX.xxxxxxxxxxxxxxxxxxxxx
2. Restart the bot: `npm start` 2. Restart the bot: `npm start`
### Step 4: Verify the Bot ### Step 4: Verify the Bot
After updating the token, the bot should: After updating the token, the bot should:
1. Login successfully: `✅ Bot logged in as AeThex#xxxx` 1. Login successfully: `✅ Bot logged in as AeThex#xxxx`
2. Load all commands: `<60><><EFBFBD> Loaded command: verify`, etc. 2. Load all commands: `<60><><EFBFBD> Loaded command: verify`, etc.
3. Start health check server: `🏥 Health check server running on port 8044` 3. Start health check server: `🏥 Health check server running on port 8044`
@ -51,6 +61,7 @@ After updating the token, the bot should:
## Token Format Validation ## Token Format Validation
A valid Discord bot token: A valid Discord bot token:
- ✅ Starts with a number (user ID) - ✅ Starts with a number (user ID)
- ✅ Contains 3 parts separated by dots: `part1.part2.part3` - ✅ Contains 3 parts separated by dots: `part1.part2.part3`
- ✅ Is ~70+ characters long - ✅ Is ~70+ characters long
@ -61,14 +72,17 @@ Example: `NTc4OTcxMjQ1NDU0OTUwNDIx.Gv-kuN.MiaXTUhlTzCqsTdwhO8sbYci0lIIY5uC08O5Ug
## Common Issues & Fixes ## Common Issues & Fixes
### Issue: "Token has been exposed" ### Issue: "Token has been exposed"
Discord automatically revokes tokens if they appear in public repositories (GitHub, etc.). Discord automatically revokes tokens if they appear in public repositories (GitHub, etc.).
**Fix:** Reset the token in Discord Developer Portal as described above. **Fix:** Reset the token in Discord Developer Portal as described above.
### Issue: Bot not in any servers ### Issue: Bot not in any servers
Even with a valid token, the bot might not connect to your servers. Even with a valid token, the bot might not connect to your servers.
**Fix:** **Fix:**
1. In Discord Developer Portal, go to **OAuth2 > URL Generator** 1. In Discord Developer Portal, go to **OAuth2 > URL Generator**
2. Select scopes: `bot` 2. Select scopes: `bot`
3. Select permissions: `Administrator` (or specific permissions) 3. Select permissions: `Administrator` (or specific permissions)
@ -76,12 +90,15 @@ Even with a valid token, the bot might not connect to your servers.
5. Select your server and authorize 5. Select your server and authorize
### Issue: "TokenInvalid" but token looks correct ### Issue: "TokenInvalid" but token looks correct
The token might be: The token might be:
- Copied with extra whitespace - Copied with extra whitespace
- Not fully copied (missing characters) - Not fully copied (missing characters)
- From a different bot application - From a different bot application
**Fix:** **Fix:**
1. Go back to Discord Developer Portal 1. Go back to Discord Developer Portal
2. Reset the token again (this revokes the old one) 2. Reset the token again (this revokes the old one)
3. Copy the full new token carefully (no extra spaces) 3. Copy the full new token carefully (no extra spaces)