Sir Stalemate is the ChessHacks discord bot. He doesn't do anything except automatically remove Discord connections when hackers intentionally leave the server.
Copy .env.example to .env and fill in the values:
DISCORD_TOKEN=your_bot_token_here
DISCORD_CLIENT_ID=your_client_id_here
API_URL=http://localhost:3000
BOT_SECRET=your_bot_secret_here- DISCORD_TOKEN & DISCORD_CLIENT_ID: From Discord Developer Portal
- API_URL:
- Local:
http://localhost:3000 - Production: Your deployed website URL (e.g.,
https://your-site.com)
- Local:
- BOT_SECRET: Must match
DISCORD_BOT_SECRETin your website's.env- Generate with:
openssl rand -base64 32 - IMPORTANT: Use the SAME value in both projects
- Generate with:
- Go to https://discord.com/developers/applications
- Select your application
- Go to Bot section
- Under Privileged Gateway Intents, enable:
- ✅ Server Members Intent (required for
guildMemberRemoveevent)
- ✅ Server Members Intent (required for
- Save changes
When a user leaves your Discord server:
- Bot receives
guildMemberRemoveevent - Bot calls your website's API:
POST /api/trpc/discord.removeConnectionByDiscordId - API removes the connection from the database
- Bot logs the result
- Start your website:
npm run dev(in Chess-Hackathon-Website) - Start the bot:
npm run dev(in discord-bot) - Have a test user leave the server
- Check bot console for logs