An AI-powered Discord bot that serves as a Dungeon Master for tabletop RPG games. Features persistent characters, combat mechanics, inventory management, interactive NPCs, multiplayer sessions, AI-driven storytelling, and a web dashboard for game management.
๐ค AI-Generated Project: This entire project was created by giving Claude Opus 4.5 a single prompt asking it to transform ussybot into an RPG Dungeon Master bot. The AI designed the architecture, implemented all features, wrote tests, and created documentation autonomously.
- Character Creation: Create persistent characters with race, class, stats, and backstory
- Stat Management: Track HP, mana, experience, and level progression
- Multiple Characters: Players can have multiple characters across different campaigns
- Character Sheet: View detailed character information with
/character sheet
- Turn-Based Combat: Initiative tracking with automatic turn order
- Actions: Attack, defend, cast spells, use items, or flee
- Status Effects: Poison, stun, buff/debuff tracking
- Combat Log: Detailed combat narration by the AI DM
- Item Management: Collect, use, and trade items
- Equipment Slots: Weapon, armor, accessory slots with stat bonuses
- Gold Economy: Earn and spend gold at shops
- Crafting: Combine items to create new ones
- Auto-Equip: Starter kits and purchased equipment can be automatically equipped to appropriate slots (e.g., weapons to main hand, armor to body).
- Quest Planning: DMs can create detailed quest plans with objectives
- Quest Progress: Track objectives and milestones
- Rewards: Automatic reward distribution on completion
- Branching Paths: Multiple quest outcomes based on player choices
- Interactive NPCs: AI-powered dialogue with persistent NPCs
- Relationships: Track player-NPC relationships and reputation
- Merchants: Buy and sell items with NPCs
- Quest Givers: NPCs can offer and track quests
- NPC Party Members: Recruit NPCs as companions who travel with you
- Loyalty System: NPC companions have loyalty (0-100) that changes based on party actions
- Combat Assistance: Party NPCs can attack, defend, heal, and use abilities in combat
- Campaign Initialization: One command generates starting location, key NPCs, and quest hooks
- World Generation: Create regions, cities, dungeons with thematic content
- Dynamic NPCs: Generate key NPCs (allies, villains, mentors) that fit your campaign theme
- Quest Generation: Auto-generate quests with objectives and scaled rewards
- Encounter Generation: Create combat, social, puzzle, or trap encounters scaled to party
- Backstory Generation: Expand character backstories with plot connections
- Loot Generation: Context-appropriate loot scaled to party level
- Theme Support: All generation respects campaign theme (Duke Nukem style, fantasy, grimdark, etc.)
- Standard Dice: Roll any dice (d4, d6, d8, d10, d12, d20, d100)
- Modifiers: Add bonuses from stats or equipment
- Advantage/Disadvantage: Roll with advantage or disadvantage
- Interactive Rolls: Buttons for quick re-rolls
- Campaign Management: Create and join campaigns
- Session Tracking: Track active sessions and participants
- Party System: Form adventuring parties
- Shared Progress: All players see the same story progression
- Session Isolation: Multiple games can run simultaneously without context bleed - the AI DM correctly tracks which characters belong to which session
- Interactive Session Menu: Use
/game listto browse, select, join, and manage sessions using a comprehensive session UI with per-session controls.
- Dynamic Narration: AI generates immersive story descriptions
- Contextual Responses: Remembers campaign history and character actions
- NPC Dialogue: Generates unique dialogue for NPCs
- Combat Descriptions: Dramatic combat narration
- Retry Logic: Automatic retry with exponential backoff for API reliability
- API Tools & Spells Support: The AI DM can cast spells, call spell/ability tool actions, and manage character resources programmatically.
- Spellcasting: Classes that cast spells (Mage, Cleric, Bard, Warlock, Paladin, Ranger, etc.) have cantrips and leveled spells, spell slots, and upcasting support.
- Spellbook: Characters can learn and prepare spells. Use
/spell learnto add spells appropriate for your class and level. - Spell Slots: Spell slots are tracked and used when casting. Recover slots via long rest or through DM control. Use
/spell slotsto view available spell slots. - Casting:
/spell castsupports cantrips (no slots), leveled spells with slot selection and upcasting, damage/healing/result summarization, and short description UI. - Class Abilities: Abilities like Second Wind, Action Surge, Sneak Attack, and Divine Smite are available and tracked with use counts.
- Game Management: View and edit sessions, characters, quests, NPCs from a web browser
- Data Editors: Edit character classes, races, items, and spells
- Real-time Sync: Changes made in the web interface are immediately available in Discord
- REST API: Full API access for custom integrations (~76 endpoints)
- Coming Soon: Browser-based chat interface to play without Discord
- Python 3.10+
- Discord Bot Token
- Requesty.ai API Key (for AI features)
- Clone the repository:
git clone https://github.com/yourusername/rpg-dm-bot.git
cd rpg-dm-bot- Install dependencies:
pip install -r requirements.txt- Create
.envfile:
cp .env.example .env
# Edit .env with your tokens- Run the bot:
python run.py- Run the web dashboard (optional, separate terminal):
cd web && uvicorn api:app --reload --port 8000
# Open http://localhost:8000 in your browserThe web dashboard provides a browser-based interface for game management:
- Start the API server:
cd web && uvicorn api:app --port 8000 - Open http://localhost:8000 in your browser
- Dashboard: Overview of active sessions, characters, and recent activity
- Sessions: Create, view, and manage game sessions
- Characters: View and edit character details, stats, inventory
- Quests: Manage quest definitions and track progress
- NPCs: Create and edit NPCs, view relationships
- Locations: Build your world map with connected locations
- Classes/Races: Edit character class and race definitions with full CRUD operations
- Skill Trees: Browse and edit class skill trees and branches
- Items/Spells: Browse and search the item and spell databases with filtering
The web dashboard is powered by a full REST API with ~80 endpoints. See web/api.py for the complete API reference. Key endpoints:
GET/POST /api/sessions- Session managementGET/POST /api/characters- Character CRUDGET/POST /api/quests- Quest managementGET/POST /api/npcs- NPC managementGET/POST /api/locations- World buildingGET/PUT /api/gamedata/classes- Class editor (full CRUD)GET/PUT /api/gamedata/races- Race editor (full CRUD)GET/PUT /api/gamedata/skills/trees/{class}- Skill tree editorGET /api/gamedata/items- Item database with filteringGET /api/gamedata/spells- Spell database with filtering
| Command | Description |
|---|---|
/character create |
Create a new character |
/character sheet |
View your character sheet |
/character stats |
View detailed stats |
/character levelup |
Level up (if eligible) |
/character switch |
Switch active character |
/character list |
List all your characters |
| Command | Description |
|---|---|
/combat start |
Start combat encounter |
/combat attack |
Attack a target |
/combat defend |
Take defensive stance |
/combat spell |
Cast a spell |
/combat item |
Use an item |
/combat flee |
Attempt to flee |
/combat status |
View combat status |
| Command | Description |
|---|---|
/spell cast |
Cast a spell from your known spells (opens a selection UI if unspecified) |
/spell list |
View all spells your character knows and their prepared state |
/spell learn |
Learn a new spell from your class spell list based on your level |
/spell info |
Get detailed spell info (damage, saving throw, components, upcasting) |
/spell slots |
View and manage your spell slots |
| Command | Description |
|---|---|
/inventory view |
View your inventory |
/inventory use |
Use an item |
/inventory equip |
Equip an item |
/inventory unequip |
Unequip an item |
/inventory drop |
Drop an item |
/inventory give |
Give item to player |
| Command | Description |
|---|---|
/quest list |
View available/active quests |
/quest info |
Get quest details |
/quest accept |
Accept a quest |
/quest complete |
Complete a quest objective |
/quest abandon |
Abandon a quest |
| Command | Description |
|---|---|
/dm quest create |
Create a new quest plan |
/dm quest edit |
Edit existing quest |
/dm npc create |
Create an NPC |
/dm spawn |
Spawn enemies |
/dm reward |
Give rewards to players |
/dm narrate |
Add story narration |
| Command | Description |
|---|---|
/session create |
Create a campaign |
/session join |
Join a campaign |
/session start |
Start a session |
/session end |
End current session |
/session players |
View party members |
/game list |
Browse and manage available games using an interactive UI |
| Command | Description |
|---|---|
/roll dice |
Roll dice (e.g., 2d6+3) |
/roll attack |
Roll attack with bonuses |
/roll save |
Roll saving throw |
/roll skill |
Roll skill check |
/roll initiative |
Roll initiative |
| Command | Description |
|---|---|
/help |
Show all commands |
/menu |
Interactive menu |
/ping |
Check bot latency |
/game start |
Start a game session (interviews for missing character info) |
/game stop |
End current game session |
/game status |
View current game state |
/game quick_start |
Create random character and start immediately |
/action |
Quick action buttons (Explore, Talk, Search, Rest, Continue) |
- Create a Character: Use
/character createto make your first character - Join a Campaign: Use
/session jointo join an existing campaign - Interact with the World: @mention the bot to talk to the DM
- Roll Dice: Use
/roll dice 1d20for any rolls needed - Learn & Cast Spells: If your class supports magic, use
/spell learnto pick spells and/spell castto cast them during play.
- Create a Campaign: Use
/session createto start a new campaign - Plan Quests: Use
/dm quest createto set up adventures - Create NPCs: Use
/dm npc createto populate your world - Run Sessions: Use
/session startwhen ready to play - Manage Sessions: Use
/game listfor a UI-driven game management experience including join, begin, pause, and reset conversation history.
rpg-dm-bot/
โโโ run.py # Entry point
โโโ requirements.txt # Dependencies
โโโ .env # Environment variables (not in repo)
โโโ .gitignore # Git ignore file
โโโ data/
โ โโโ rpg.db # SQLite database (created at runtime)
โ โโโ game_data/ # Static game data (classes, races, items)
โโโ logs/ # Log files
โโโ src/
โ โโโ bot.py # Main bot class
โ โโโ database.py # Database operations
โ โโโ llm.py # LLM integration
โ โโโ prompts.py # System prompts
โ โโโ tools.py # Tool executor
โ โโโ tool_schemas.py # Tool definitions
โ โโโ cogs/
โ โโโ characters.py # Character management
โ โโโ combat.py # Combat system
โ โโโ inventory.py # Inventory management
โ โโโ quests.py # Quest system
โ โโโ npcs.py # NPC interactions
โ โโโ dice.py # Dice rolling
โ โโโ spells.py # Spells, spell slot management, and casting UI
โ โโโ sessions.py # Session management
โ โโโ dm_chat.py # AI chat/narration
โ โโโ game_master.py # Game flow management
โโโ tests/ # Unit tests
Contributions are welcome! Please feel free to submit issues and pull requests.
MIT License - feel free to use this for your own RPG adventures!
- Built with discord.py
- AI powered by Requesty.ai
- Inspired by classic tabletop RPGs
- Originally transformed from ussybot by Claude Opus 4.5