major-domo-v2/commands/league/__init__.py
Cal Corum 2409c27c1d CLAUDE: Add comprehensive scorecard submission system
Implements full Google Sheets scorecard submission with:
- Complete game data extraction (68 play fields, pitching decisions, box score)
- Transaction rollback support at 3 states (plays/game/complete)
- Duplicate game detection with confirmation dialog
- Permission-based submission (GMs only)
- Automated results posting to news channel
- Automatic standings recalculation
- Key plays display with WPA sorting

New Components:
- Play, Decision, Game models with full validation
- SheetsService for Google Sheets integration
- GameService, PlayService, DecisionService for data management
- ConfirmationView for user confirmations
- Discord helper utilities for channel operations

Services Enhanced:
- StandingsService: Added recalculate_standings() method
- CustomCommandsService: Fixed creator endpoint path
- Team/Player models: Added helper methods for display

Configuration:
- Added SHEETS_CREDENTIALS_PATH environment variable
- Added SBA_NETWORK_NEWS_CHANNEL and role constants
- Enabled pygsheets dependency

Documentation:
- Comprehensive README updates across all modules
- Added command, service, model, and view documentation
- Detailed workflow and error handling documentation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-16 00:21:32 -05:00

56 lines
1.8 KiB
Python

"""
League command package for Discord Bot v2.0
Provides league-wide slash commands for standings and current state.
"""
import logging
from typing import List, Tuple, Type
import discord
from discord.ext import commands
from .info import LeagueInfoCommands
from .standings import StandingsCommands
from .schedule import ScheduleCommands
from .submit_scorecard import SubmitScorecardCommands
logger = logging.getLogger(f'{__name__}.setup_league')
async def setup_league(bot: commands.Bot) -> Tuple[int, int, List[str]]:
"""
Set up league command modules.
Returns:
Tuple of (successful_loads, failed_loads, failed_modules)
"""
league_cogs: List[Tuple[str, Type[commands.Cog]]] = [
("LeagueInfoCommands", LeagueInfoCommands),
("StandingsCommands", StandingsCommands),
("ScheduleCommands", ScheduleCommands),
("SubmitScorecardCommands", SubmitScorecardCommands),
]
successful = 0
failed = 0
failed_modules = []
for cog_name, cog_class in league_cogs:
try:
await bot.add_cog(cog_class(bot))
logger.info(f"✅ Loaded league command module: {cog_name}")
successful += 1
except Exception as e:
logger.error(f"❌ Failed to load league command module {cog_name}: {e}")
failed += 1
failed_modules.append(cog_name)
# Log summary
if failed == 0:
logger.info(f"🎉 All {successful} league command modules loaded successfully")
else:
logger.warning(f"⚠️ League commands loaded with issues: {successful} successful, {failed} failed")
if failed_modules:
logger.warning(f"Failed modules: {', '.join(failed_modules)}")
return successful, failed, failed_modules