A Discord bot for managing Capture The Flag challenges with slash commands for creating challenges, submitting flags, and viewing the leaderboard.
/createchallenge– Opens a modal for privileged users to publish a challenge announcement in the configured channel. Collects title, description, flag, flag format, optional file links, points, and difficulty. Flags are stored securely and never shown in public messages./submit– Allows players to select a challenge and submit a flag. Correct submissions award the challenge's points; duplicate solves are detected./leaderboard– Displays the current standings, including total points and number of solves per player.
- Python 3.10+
- A Discord application with a bot token and the necessary gateway intents (
Server Members Intentis required for leaderboard names).
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.envfile in the project root containing:DISCORD_BOT_TOKEN=your_bot_token_here # Comma-separated list of guild IDs for faster command sync (optional) DISCORD_GUILD_IDS=123456789012345678,987654321098765432 # Channel ID where new challenges should be announced (optional) CHALLENGES_CHANNEL_ID=123456789012345678
-
Invite the bot to your server with the
applications.commandsandbotscopes. Grant it the permissions needed to post in the challenges channel. -
Run the bot:
python -m bot.bot
- Only members with the
Manage Serverpermission can run/createchallenge. - If
CHALLENGES_CHANNEL_IDis not set or cannot be found, new challenges are posted in the channel where the command was used. - Challenge data and leaderboard progress are stored in
data/store.json.
Challenge storage is file-based JSON for simplicity. If you need to reset the state, delete data/store.json while the bot is offline.