Skip to content

ChessHacks/sir-stalemate

Repository files navigation

Sir Stalemate

Sir Stalemate is the ChessHacks discord bot. He doesn't do anything except automatically remove Discord connections when hackers intentionally leave the server.

Discord Bot Setup

Environment Variables

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

Getting the Values:

  1. DISCORD_TOKEN & DISCORD_CLIENT_ID: From Discord Developer Portal
  2. API_URL:
    • Local: http://localhost:3000
    • Production: Your deployed website URL (e.g., https://your-site.com)
  3. BOT_SECRET: Must match DISCORD_BOT_SECRET in your website's .env
    • Generate with: openssl rand -base64 32
    • IMPORTANT: Use the SAME value in both projects

Discord Developer Portal Setup

  1. Go to https://discord.com/developers/applications
  2. Select your application
  3. Go to Bot section
  4. Under Privileged Gateway Intents, enable:
    • Server Members Intent (required for guildMemberRemove event)
  5. Save changes

How It Works

When a user leaves your Discord server:

  1. Bot receives guildMemberRemove event
  2. Bot calls your website's API: POST /api/trpc/discord.removeConnectionByDiscordId
  3. API removes the connection from the database
  4. Bot logs the result

Testing

  1. Start your website: npm run dev (in Chess-Hackathon-Website)
  2. Start the bot: npm run dev (in discord-bot)
  3. Have a test user leave the server
  4. Check bot console for logs

About

get out ‼️

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors