paper-dynasty-discord/CLAUDE.md
Cal Corum 035cd8888f
All checks were successful
Ruff Lint / lint (pull_request) Successful in 22s
fix: move health server from port 8080 to 8081 (#130)
Adminer is exposed on host port 8080, shadowing the bot health endpoint.
Change health server default to 8081 to avoid the conflict.

Closes #130

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 23:33:09 -05:00

2.6 KiB

Paper Dynasty Discord Bot

Baseball card game Discord bot. discord.py with cog-based commands, SQLModel for database ops.

Commands

python -m pytest                    # Run tests
python paperdynasty.py              # Start bot
pip install -r requirements.txt     # Install dependencies

Architecture

  • Cogs (cogs/): Command modules — gameplay, economy, players, admins
  • Game engine (in_game/): Turn-based simulation, AI manager, dice mechanics, WPA calculations
  • UI (utilities/): Buttons, dropdowns, embeds
  • Database: Production uses FastAPI database directly; dev may use separate PostgreSQL via SQLModel

Key Patterns

  • Cards generated from MLB statistics with complex rating calculations
  • Card ratings split by handedness (vs_hand: 'R' or 'L')
  • Multiple cardsets (seasons) with different priorities for gameplay
  • Use factory data in testing as often as possible

Deployment & Troubleshooting

Production

  • Host: ssh sba-bots (10.10.0.88, alias pd-bots)
  • Path: /home/cal/container-data/paper-dynasty
  • Container: paper-dynasty_discord-app_1
  • Image: manticorum67/paper-dynasty-discordapp
  • Health: GET http://localhost:8081/health (HTTP server in health_server.py)
  • Versioning: CalVer (YYYY.M.BUILD) — manually tagged when ready to release

Logs

  • Container logs: ssh sba-bots "docker logs --since 1h paper-dynasty_discord-app_1"
  • Log file (in container): /usr/src/app/logs/discord.log (rotating, 32MB, 5 backups)
  • Dev log mount: ../dev-logs/usr/src/app/logs

Key Env Vars

BOT_TOKEN, GUILD_ID, API_TOKEN, DATABASE (Dev/Prod), LOG_LEVEL, SCOREBOARD_CHANNEL, TZ=America/Chicago

Common Issues

  • Bot not responding → check docker logs, verify BOT_TOKEN and GUILD_ID
  • API errors → verify DATABASE is set to Prod or Dev, check API_TOKEN matches the database API
  • Game engine errors → check /usr/src/app/logs/discord.log for detailed tracebacks
  • Health endpoint not responding → health_server.py runs on port 8081 inside the container

CI/CD

Ruff lint on PRs. Docker image built on CalVer tag push only.

# Release: git tag YYYY.M.BUILD && git push origin YYYY.M.BUILD
tea pulls create --repo cal/paper-dynasty --head <branch> --base main --title "title" --description "description"

Other Containers on Same Host

paper-dynasty_adminer_1, paper-dynasty_db_1, sba-website_sba-web_1, sba-ghost_sba-ghost_1

Development Notes

  • Connect to proper docker socket when running tests
  • Plans go in ./.claude/plans/ with descriptive filenames