Updates bot.js to make Supabase integration optional, adds Sentinel security listeners, and modifies several commands to handle missing Supabase configurations gracefully. Also updates package.json and replit.md for new dependencies and features. Replit-Commit-Author: Agent Replit-Commit-Session-Id: aed2e46d-25bb-4b73-81a1-bb9e8437c261 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Event-Id: 0d645005-4840-49ef-9446-2c62d2bb7eed Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3bdfff67-975a-46ad-9845-fbb6b4a4c4b5/aed2e46d-25bb-4b73-81a1-bb9e8437c261/Wmps8l5 Replit-Helium-Checkpoint-Created: true
5 KiB
AeThex Discord Bot - Spaceship Deployment Guide
📋 Prerequisites
- Spaceship hosting account with Node.js support
- Discord bot credentials (already in your environment variables)
- Supabase project credentials
- Git access to your repository
🚀 Deployment Steps
Step 1: Prepare the Bot Directory
Ensure all bot files are committed:
code/discord-bot/
├── bot.js
├── package.json
├── .env.example
├── Dockerfile
└── commands/
├── verify.js
├── set-realm.js
├── profile.js
├── unlink.js
└── verify-role.js
Step 2: Create Node.js App on Spaceship
- Log in to your Spaceship hosting dashboard
- Click "Create New Application"
- Select Node.js as the runtime
- Name it:
aethex-discord-bot - Select your repository and branch
Step 3: Configure Environment Variables
In Spaceship Application Settings → Environment Variables, add:
DISCORD_BOT_TOKEN=<your_bot_token_from_discord_developer_portal>
DISCORD_CLIENT_ID=<your_client_id>
DISCORD_PUBLIC_KEY=<your_public_key>
SUPABASE_URL=<your_supabase_url>
SUPABASE_SERVICE_ROLE=<your_service_role_key>
BOT_PORT=3000
NODE_ENV=production
Note: Get these values from:
- Discord Developer Portal: Applications → Your Bot → Token & General Information
- Supabase Dashboard: Project Settings → API
Step 4: Configure Build & Run Settings
In Spaceship Application Settings:
Build Command:
npm install
Start Command:
npm start
Root Directory:
code/discord-bot
Step 5: Deploy
- Click "Deploy" in Spaceship dashboard
- Monitor logs for:
✅ Bot logged in as <BOT_NAME>#<ID> 📡 Listening in X server(s) ✅ Successfully registered X slash commands.
Step 6: Verify Bot is Online
Once deployed:
- Go to your Discord server
- Type
/verify- the command autocomplete should appear - Bot should be online with status "Listening to /verify to link your AeThex account"
📡 Discord Bot Endpoints
The bot will be accessible at:
https://<your-spaceship-domain>/
The bot uses Discord's WebSocket connection (not HTTP), so it doesn't need to expose HTTP endpoints. It listens to Discord events via client.login(DISCORD_BOT_TOKEN).
🔌 API Integration
Frontend calls to link Discord accounts:
- Endpoint:
POST /api/discord/link - Body:
{ verification_code, user_id } - Response:
{ success: true, message: "..." }
Discord Verify page (/discord-verify?code=XXX) will automatically:
- Call
/api/discord/linkwith the verification code - Link the Discord ID to the AeThex user account
- Redirect to dashboard on success
🛠️ Debugging
Check bot logs on Spaceship:
- Application → Logs
- Filter for "bot.js" or "error"
Common issues:
"Discord bot not responding to commands"
- Check:
DISCORD_BOT_TOKENis correct - Check: Bot is added to the Discord server with "applications.commands" scope
- Check: Spaceship logs show "✅ Logged in"
"Supabase verification fails"
- Check:
SUPABASE_URLandSUPABASE_SERVICE_ROLEare correct - Check:
discord_linksanddiscord_verificationstables exist - Run migration:
code/supabase/migrations/20250107_add_discord_integration.sql
"Slash commands not appearing in Discord"
- Check: Logs show "✅ Successfully registered X slash commands"
- Discord may need 1-2 minutes to sync commands
- Try typing
/in Discord to force refresh - Check: Bot has "applications.commands" permission in server
📊 Monitoring
Key metrics to monitor:
- Bot uptime (should be 24/7)
- Command usage (in Supabase)
- Verification code usage (in Supabase)
- Discord role sync success rate
View in Admin Dashboard:
- AeThex Admin Panel → Discord Management tab
- Shows:
- Bot status
- Servers connected
- Linked accounts count
- Role mapping status
🔄 Updating the Bot
- Make code changes locally
- Test with
npm start - Commit and push to your branch
- Spaceship will auto-deploy on push
- Monitor logs to ensure deployment succeeds
🆘 Support
For issues:
- Check Spaceship logs
- Review
/api/discord/linkendpoint response - Verify all environment variables are set correctly
- Ensure Supabase tables exist and have correct schema
📝 Database Setup
Run this migration on your AeThex Supabase:
-- From code/supabase/migrations/20250107_add_discord_integration.sql
-- This creates:
-- - discord_links (links Discord ID to AeThex user)
-- - discord_verifications (temporary verification codes)
-- - discord_role_mappings (realm → Discord role mapping)
-- - discord_user_roles (tracking assigned roles)
🎉 You're All Set!
Once deployed, users can:
- Click "Link Discord" in their profile settings
- Type
/verifyin Discord - Click the verification link
- Their Discord account is linked to their AeThex account
- They can use
/set-realm,/profile,/unlink, and/verify-rolecommands
Deployment Date: <date>
Bot Status: <status>
Last Updated: <timestamp>