major-domo-v2/commands/league
Cal Corum 1dd930e4b3 CLAUDE: Complete dice command system with fielding mechanics
Implements comprehensive dice rolling system for gameplay:

## New Features
- `/roll` and `!roll` commands for XdY dice notation with multiple roll support
- `/ab` and `!atbat` commands for baseball at-bat dice shortcuts (1d6;2d6;1d20)
- `/fielding` and `!f` commands for Super Advanced fielding with full position charts

## Technical Implementation
- Complete dice command package in commands/dice/
- Full range and error charts for all 8 defensive positions (1B,2B,3B,SS,LF,RF,CF,C)
- Pre-populated position choices for user-friendly slash command interface
- Backwards compatibility with prefix commands (!roll, !r, !dice, !ab, !atbat, !f, !fielding, !saf)
- Type-safe implementation following "Raise or Return" pattern

## Testing & Quality
- 30 comprehensive tests with 100% pass rate
- Complete test coverage for all dice functionality, parsing, validation, and error handling
- Integration with bot.py command loading system
- Maintainable data structures replacing verbose original implementation

## User Experience
- Consistent embed formatting across all commands
- Detailed fielding results with range and error analysis
- Support for complex dice combinations and multiple roll formats
- Clear error messages for invalid inputs

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 22:30:31 -05:00
..
__init__.py CLAUDE: Major bot enhancements - Admin commands, player stats, standings, schedules 2025-08-28 15:32:38 -05:00
info.py CLAUDE: Major bot enhancements - Admin commands, player stats, standings, schedules 2025-08-28 15:32:38 -05:00
README.md Transactions cog in place 2025-09-24 09:32:04 -05:00
schedule.py Transactions cog in place 2025-09-24 09:32:04 -05:00
standings.py CLAUDE: Complete dice command system with fielding mechanics 2025-09-24 22:30:31 -05:00

League Commands

This directory contains Discord slash commands related to league-wide information and statistics.

Files

info.py

  • Command: /league
  • Description: Display current league status and information
  • Functionality: Shows current season/week, phase (regular season/playoffs/offseason), transaction status, trade deadlines, and league configuration
  • Service Dependencies: league_service.get_current_state()
  • Key Features:
    • Dynamic phase detection (offseason, playoffs, regular season)
    • Transaction freeze status
    • Trade deadline and playoff schedule information
    • Draft pick trading status

standings.py

  • Commands:
    • /standings - Display league standings by division
    • /playoff-picture - Show current playoff picture and wild card race
  • Parameters:
    • season: Optional season number (defaults to current)
    • division: Optional division filter for standings
  • Service Dependencies: standings_service
  • Key Features:
    • Division-based standings display
    • Games behind calculations
    • Recent form statistics (home record, last 8 games, current streak)
    • Playoff cutoff visualization
    • Wild card race tracking

schedule.py

  • Commands:
    • /schedule - Display game schedules
    • /results - Show recent game results
  • Parameters:
    • season: Optional season number (defaults to current)
    • week: Optional specific week filter
    • team: Optional team abbreviation filter
  • Service Dependencies: schedule_service
  • Key Features:
    • Weekly schedule views
    • Team-specific schedule filtering
    • Series grouping and summary
    • Recent/upcoming game overview
    • Game completion tracking

Architecture Notes

Decorator Usage

All commands use the @logged_command decorator pattern:

  • Eliminates boilerplate logging code
  • Provides consistent error handling
  • Automatic request tracing and timing

Error Handling

  • Graceful fallbacks for missing data
  • User-friendly error messages
  • Ephemeral responses for errors

Embed Structure

  • Uses EmbedTemplate for consistent styling
  • Color coding based on context (success/error/info)
  • Rich formatting with team logos and thumbnails

Troubleshooting

Common Issues

  1. No league data available: Check league_service.get_current_state() API endpoint
  2. Standings not loading: Verify standings_service.get_standings_by_division() returns valid data
  3. Schedule commands failing: Ensure schedule_service methods are properly handling season/week parameters

Dependencies

  • services.league_service
  • services.standings_service
  • services.schedule_service
  • utils.decorators.logged_command
  • views.embeds.EmbedTemplate
  • constants.SBA_CURRENT_SEASON

Testing

Run tests with: python -m pytest tests/test_commands_league.py -v