The official Discord bot for the mge.tf community.
- Account Verification — Users link their Discord on mge.tf, then run
/verifyto automatically receive server roles. Supports cross-checking profile URLs and provides detailed feedback when links don't match.
bun installcp .env.example .envEdit .env:
# Discord application credentials
DISCORD_BOT_TOKEN=your_bot_token_here
DISCORD_APPLICATION_ID=your_application_id_here
# Optional: guild-scoped command deployment (faster — use during development)
DISCORD_GUILD_ID=your_guild_id_here
# mge.tf API — generate a key in the admin panel under Site > API Keys
MGE_API_URL=https://mge.tf
MGE_API_KEY=mge_your_api_key_here
# Comma-separated role IDs to add on successful verification
VERIFY_ADD_ROLE_IDS=role_id_1,role_id_2
# Optional: comma-separated role IDs to remove on successful verification
VERIFY_REMOVE_ROLE_IDS=
# Optional: restrict /verify to a specific channel
VERIFICATION_CHANNEL_ID=- Go to the Discord Developer Portal
- Create a new application and add a Bot user
- Under Privileged Gateway Intents, enable Server Members Intent (required for role assignment)
- Copy the bot token to
DISCORD_BOT_TOKEN
- Log in to mge.tf as a head admin
- Go to Admin → Site → API Keys
- Create a new key (e.g. "Discord Bot")
- Copy the key to
MGE_API_KEY
# Guild deploy — instant, use during development (requires DISCORD_GUILD_ID)
bun run deploy-commands
# Global deploy — takes up to 1 hour to propagate, use for production
bun run deploy-commands --globalbun run start| Command | Description |
|---|---|
/verify |
Verify your mge.tf account and receive server roles |
/verify profile:<url> |
Same as above, but cross-checks the provided mge.tf profile URL |
src/
├── index.ts # Entry point
├── client.ts # Discord client + intents
├── env.ts # Environment variable validation (Zod)
├── types.d.ts # Type definitions
├── deploy.ts # Slash command deployment script
├── commands/
│ └── verify.ts # /verify command
├── events/
│ ├── ready.ts # Bot ready handler
│ └── interaction-create.ts # Command router
└── utils/
├── api.ts # mge.tf API client
├── core.ts # Dynamic command/event loader
├── logger.ts # Pino logger
└── error-handler.ts # Global error handlers
- Create a project on Railway and connect this repository
- Set all environment variables in the Railway dashboard
- Railway will build and deploy automatically via the included
Dockerfile
Or deploy via CLI:
railway updocker build -t mgetf-discord-bot .
docker run -d --env-file .env mgetf-discord-bot| Command | Description |
|---|---|
bun run start |
Start the bot |
bun run deploy-commands |
Deploy slash commands to guild |
bun run deploy-commands --global |
Deploy slash commands globally |
bun run lint |
Run Biome linter |
bun run fmt |
Format code with Biome |
bun run check |
Lint + format |
bun run typecheck |
TypeScript type check |