A full-featured Discord bot for the Minecadia community: leveling, achievements, DM games, chat games, counting, daily rewards, leaderboards, and admin tooling. All game progress and XP are persisted to a MySQL database with config-driven behavior.
- Features overview
- Tech stack
- Quick start
- Project structure
- Documentation index
- Configuration
- Running the bot
- Contributing
| Area | Description |
|---|---|
| DM games | Wordle, Tic-Tac-Toe, Connect Four, Memory, 2048, Minesweeper, Hangman — play in DMs with cooldowns, XP, and win tracking. See Games (DM & chat). |
| Chat games | Trivia, Unscramble, Flag Guesser, Math Quiz, Emoji Quiz, Guess the Number — auto-rotating games in configured channels with position-based XP. |
| Leveling & XP | XP from games, daily rewards, milestones, and manual grants; levels from levels/leveling config; debouncing, admin logs, level-up DMs. See Leveling & achievements. |
| Achievements & milestones | Per-game and global milestones (wins, total games, best score, level, total XP); badge selection and display; milestone XP granted via LevelingManager. |
| Counting | Counting channel with streaks and statistics; optional role rewards. |
| Daily rewards | Cooldown-based daily XP claim. |
| Leaderboards | Monthly wipe, all-time XP/level leaderboards, top winners, monthly champion achievement + XP. |
| Statistics | Per-user game stats (wins, plays, scores) and level/XP overview. |
| Practice mode | Test-mode games (no XP/DB) for Trivia, Math Quiz, Flag Guesser, Unscramble, Emoji Quiz in #games. |
| Admin | Config get/set/reload, game toggles, force chat game, add/remove XP, wipe levels, logs viewer, chat game admin UI. |
- Python 3 with discord.py (commands + app_commands)
- MySQL via aiomysql (async connection pool)
- JSON configs under
assets/Configs/(games, leveling, milestones, rewards, etc.) - Singleton/core services: ConfigManager, DatabasePool, CacheManager, LevelingManager, MilestonesManager, GameManager
-
Clone and install
git clone <repo_url> cd MinecadiaGames pip install -r requirements.txt
-
Configure
- Copy
.env.exampleto.envand fill in your values. The bot reads these first;.envis in.gitignoreso secrets stay private. - Required in .env:
DISCORD_TOKEN(your bot token). - Database (recommended in .env): Set
DB_HOST,DB_USER,DB_PASSWORD,DB_NAME(and optionallyDB_PORT,DB_AUTOCOMMIT). IfDB_HOSTis set, the bot uses these instead ofassets/Configs/bot.jsonfor the database connection. - Optional: You can instead set
tokenanddatabaseinassets/Configs/bot.json(not recommended for production; avoid committing real secrets). - Edit
assets/Configs/bot.jsonandassets/Configs/discord.jsonas needed for presence, guild/channel IDs, etc. (see Configuration). - Ensure MySQL is running and the database/schema exist (see Architecture).
- Copy
-
Run
python bot.py
The bot loads all cogs from
cogs/, initializes the database pool and cache, starts the GameManager (chat + DM loops), and registers persistent views.
MinecadiaGames/
├── bot.py # Entry point, MinecadiaBot, extension loading, view registration
├── assets/Configs/ # JSON configs (bot, discord, dm_games, chat_games, milestones, levels, etc.)
├── core/ # Config, database pool, cache, logging
├── cogs/ # Discord cogs (commands + listeners)
├── games/ # Game logic
│ ├── base/ # Base classes (game, dm_game, chat_game)
│ ├── dm/ # Wordle, TicTacToe, Connect Four, Memory, 2048, Minesweeper, Hangman
│ └── chat/ # Trivia, Unscramble, Flag Guesser, Math Quiz, Emoji Quiz, Guess the Number
├── managers/ # GameManager, LevelingManager, MilestonesManager
├── ui/ # Shared views (DM games menu, sendgames, leaderboards)
├── utils/ # Achievements, helpers, paginator, chat game registry
└── docs/ # Detailed documentation (linked below)
| Document | Contents |
|---|---|
| Games (DM & chat) | All DM and chat games, config locations, XP, achievements, practice mode. |
| Leveling & achievements | XP flow, level formula, milestones, badge selection, where XP is granted (including all games + monthly champion). |
| Configuration | Config files, ConfigManager keys, env/security notes. |
| Commands & cogs | Slash commands, prefix commands, and cog list. |
| Architecture | Core services, database usage, managers, run flow. |
- Secrets in .env (recommended): Copy
.env.exampleto.envand setDISCORD_TOKENand, for the database,DB_HOST,DB_USER,DB_PASSWORD,DB_NAME(and optionallyDB_PORT,DB_AUTOCOMMIT). The bot uses these first;.envis in.gitignoreso they are never committed. You can fall back totokenanddatabaseinassets/Configs/bot.jsonif you leave the env vars unset. - Rest of config: Set in
assets/Configs/bot.jsonandassets/Configs/discord.json. The app readsconfigas a merge ofbot+discord(see Configuration). - Game behavior: DM games →
assets/Configs/dm_games.json; chat games →assets/Configs/chat_games.jsonandassets/Configs/games/*.json. - Leveling:
assets/Configs/leveling.jsonandassets/Configs/levels.json. - Milestones:
assets/Configs/milestones.json. - Rewards / winners:
assets/Configs/rewards.json,assets/Configs/winners.json.
Do not commit real tokens or database credentials; use env vars or local overrides as needed.
python bot.py- Requires a valid Discord token and MySQL reachable with the configured
DATABASE_CONFIG. - Cogs are loaded from
cogs/(all.pyfiles that don’t start with_). - On ready: GameManager starts chat and DM game loops; Wordle, Minesweeper, and Hangman listeners are registered; persistent views (config, logs, milestones, statistics, paginator, chat game admin) are added.
- Follow existing patterns: config-driven options, async DB via
DatabasePool, XP viaLevelingManager, achievements viautils.achievementsandMilestonesManager.check_achievementswithuser/channel/clientwhen awarding milestone XP. - New games: DM games extend the base in
games/dm/and register inGameManager.dm_games; chat games extend the base ingames/chat/and are invoked by the chat game loop (see Games and Architecture).
For full detail on every feature, use the documentation index above.