6.5 KiB
Discord Activity Deployment Guide
For Web-Based Development (No Terminal Access)
If you can't run npm in your development environment, follow this guide to deploy Discord Activity and register commands via the web.
Step 1: Set Environment Variables
Add these to your deployment platform (Vercel, PebbleHost):
Vercel (Frontend)
VITE_DISCORD_CLIENT_ID=578971245454950421
PebbleHost (Discord Bot)
DISCORD_BOT_TOKEN=<your-token>
DISCORD_CLIENT_ID=578971245454950421
DISCORD_PUBLIC_KEY=<your-public-key>
SUPABASE_URL=https://kmdeisowhtsalsekkzqd.supabase.co
SUPABASE_SERVICE_ROLE=<your-service-role-key>
BOT_PORT=3000
Vercel (Backend - for command registration)
DISCORD_BOT_TOKEN=<your-token>
DISCORD_CLIENT_ID=578971245454950421
DISCORD_ADMIN_REGISTER_TOKEN=<create-a-random-secure-token>
Step 2: Enable Discord Activities
- Go to Discord Developer Portal
- Select your application (AeThex)
- Go to Settings → General Information
- Scroll down to Activities
- Enable Activities (toggle ON)
- Set Activity URL:
https://aethex.dev/activityorhttps://aethex.dev/ - Save changes
When you enable Activities, Discord automatically creates an "Entry Point" command. This is expected and OK.
Step 3: Register Discord Commands via Web API
Instead of running npm run register-commands, use this web endpoint:
Option A: Using curl (if you have PebbleHost console access)
curl -X POST https://aethex.dev/api/discord/admin-register-commands \
-H "Authorization: Bearer YOUR_DISCORD_ADMIN_REGISTER_TOKEN" \
-H "Content-Type: application/json"
Replace YOUR_DISCORD_ADMIN_REGISTER_TOKEN with the value you set in environment variables.
Option B: Call from Admin Panel (Future)
You can add a button to /admin panel that triggers this endpoint:
async function registerCommands() {
const response = await fetch("/api/discord/admin-register-commands", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DISCORD_ADMIN_REGISTER_TOKEN}`,
"Content-Type": "application/json",
},
});
const data = await response.json();
console.log("Registration result:", data);
}
Option C: Using Postman
- Create a new POST request to:
https://aethex.dev/api/discord/admin-register-commands - Go to Headers tab
- Add:
- Key:
Authorization - Value:
Bearer YOUR_DISCORD_ADMIN_REGISTER_TOKEN
- Key:
- Click Send
Step 4: Deploy Bot to PebbleHost
- Create a new Node.js app on PebbleHost
- Point it to
code/discord-bot/directory - Set build command:
npm install - Set start command:
npm start - Add environment variables (from Step 1)
- Deploy
The bot will start and listen for commands. ✅
Command registration happens via the API endpoint (Step 3), not on bot startup.
Step 5: Deploy Frontend to Vercel
- Connect your GitHub repo to Vercel (or push code)
- Add environment variables (from Step 1)
- Deploy
- Frontend will auto-build and serve
/activityroute
Step 6: Test Discord Activity
- Open Discord
- Go to a server where your bot is installed
- Click your bot's profile
- Click Launch (or the Activity button if visible)
- Your Activity should load in an iframe
- You should be instantly authenticated (no login needed)
Troubleshooting
Error 50240: "Cannot remove Entry Point command"
This happens if:
- You enable Activities, then the bot tries to register commands via bulk update
- The bot is trying to overwrite the auto-generated Entry Point command
Solution:
- ✅ Your bot code has been fixed (bot no longer registers on startup)
- Just call the
/api/discord/admin-register-commandsendpoint (Step 3) - The endpoint handles Error 50240 gracefully
Activity not loading in Discord
Check:
- Activities enabled in Discord Developer Portal ✅
- Activity URL is set to
https://aethex.dev/activity(not an IP) ✅ - Frontend is deployed to Vercel ✅
- Environment variable
VITE_DISCORD_CLIENT_IDis set ✅ - Check browser console for errors (F12)
"Unauthorized" error when calling register endpoint
Check:
DISCORD_ADMIN_REGISTER_TOKENis set in Vercel environment variables- You're passing the correct token in the
Authorization: Bearerheader - The token matches exactly (no extra spaces)
Bot not responding to commands
Check:
- Bot is online on PebbleHost (check logs)
- Commands are registered (call
/api/discord/admin-register-commandsand check response) - Response shows commands registered successfully
- Try the commands in Discord (
/verify,/profile, etc.)
Quick Reference
| What | How |
|---|---|
| Enable Activities | Discord Developer Portal → Settings → Activities → Enable |
| Register Commands | POST to /api/discord/admin-register-commands with auth token |
| Deploy Bot | Push to PebbleHost, bot starts with npm start |
| Deploy Frontend | Push to GitHub, Vercel auto-deploys |
| Test Activity | Open Discord, click Activity button, should load |
Environment Variables Checklist
DISCORD_BOT_TOKEN- Set on PebbleHostDISCORD_CLIENT_ID- Set on PebbleHost & VercelDISCORD_PUBLIC_KEY- Set on PebbleHostSUPABASE_URL- Set on PebbleHostSUPABASE_SERVICE_ROLE- Set on PebbleHostVITE_DISCORD_CLIENT_ID- Set on Vercel (frontend)DISCORD_ADMIN_REGISTER_TOKEN- Set on Vercel (backend)
What Happens When You Register Commands
The endpoint registers these 5 commands:
/verify- Generate linking code (15-min expiry)/set-realm- Choose primary arm (labs, gameforge, corp, foundation, devlink)/profile- View linked AeThex profile/unlink- Disconnect Discord account/verify-role- Check assigned Discord roles
Plus the auto-generated Entry Point command (managed by Discord for Activities).
Summary
✅ No need to run npm in the web
✅ Everything can be deployed via web interfaces
✅ Commands registered via API endpoint
✅ Error 50240 handled automatically
✅ Activity loads instantly in Discord
You're all set! 🚀