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> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| info.py | ||
| README.md | ||
Player Commands
This directory contains Discord slash commands for player information and statistics.
Files
info.py
- Command:
/player - Description: Display comprehensive player information and statistics
- Parameters:
name(required): Player name to search forseason(optional): Season for statistics (defaults to current season)
- Service Dependencies:
player_service.get_players_by_name()player_service.search_players_fuzzy()player_service.get_player()stats_service.get_player_stats()
Key Features
Player Search
- Exact Name Matching: Primary search method using player name
- Fuzzy Search Fallback: If no exact match, suggests similar player names
- Multiple Player Handling: When multiple players match, attempts exact match or asks user to be more specific
- Suggestion System: Shows up to 10 suggested players with positions when no exact match found
Player Information Display
- Basic Info: Name, position(s), team, season
- Statistics Integration:
- Batting stats (AVG/OBP/SLG, OPS, wOBA, HR, RBI, runs, etc.)
- Pitching stats (W-L record, ERA, WHIP, strikeouts, saves, etc.)
- Two-way player detection and display
- Visual Elements:
- Team logo as author icon
- Player card image as main image
- Thumbnail priority: fancy card → headshot → team logo
- Team color theming for embed
Advanced Features
- Concurrent Data Fetching: Player data and statistics retrieved in parallel for performance
- sWAR Display: Shows Strat-o-Matic WAR value
- Multi-Position Support: Displays all eligible positions
- Rich Error Handling: Graceful fallbacks when data is unavailable
Architecture Notes
Search Logic Flow
- Search by exact name in specified season
- If no results, try fuzzy search across all players
- If single result, display player card
- If multiple results, attempt exact name match
- If still multiple, show disambiguation list
Performance Optimizations
asyncio.gather()for concurrent API calls- Efficient player data and statistics retrieval
- Lazy loading of optional player images
Error Handling
- No players found: Suggests fuzzy matches
- Multiple matches: Provides clarification options
- Missing data: Shows partial information with clear indicators
- API failures: Graceful degradation with fallback data
Troubleshooting
Common Issues
-
Player not found:
- Check player name spelling
- Verify player exists in the specified season
- Use fuzzy search suggestions
-
Statistics not loading:
- Verify
stats_service.get_player_stats()API endpoint - Check if player has statistics for the requested season
- Ensure season parameter is valid
- Verify
-
Images not displaying:
- Check player image URLs in database
- Verify team thumbnail URLs
- Ensure image hosting is accessible
-
Performance issues:
- Monitor concurrent API call efficiency
- Check database query performance
- Verify embed size limits
Dependencies
services.player_serviceservices.stats_serviceutils.decorators.logged_commandviews.embeds.EmbedTemplateconstants.SBA_CURRENT_SEASONexceptions.BotException
Testing
Run tests with: python -m pytest tests/test_commands_players.py -v
Database Requirements
- Player records with name, positions, team associations
- Statistics tables for batting and pitching
- Image URLs for player cards, headshots, and fancy cards
- Team logo and color information