major-domo-v2/commands/transactions/__init__.py
Cal Corum 36ecd1b3ff CLAUDE: Add /ilmove command for real-time roster moves with organizational affiliate support
Implemented comprehensive /ilmove command system for immediate roster changes (IL moves,
activations, etc.) that execute instantly for the current week, complementing the existing
/dropadd system which schedules moves for next week.

New Features:
- /ilmove command: Interactive transaction builder for THIS week (immediate execution)
- /clearilmove command: Clear current IL move transaction builder
- Dual-mode transaction system: Scheduled (/dropadd) vs Immediate (/ilmove)

Key Fixes:
- Organizational team matching: Minor League players (WVMiL) now correctly recognized as
  valid targets for their Major League organization (WV)
- Transaction POST format: Fixed to use correct batch API format with count/moves structure
- RosterType to team affiliate mapping: Moves to IL now correctly assign players to WVIL
  instead of WV, and moves from MiL correctly reference WVMiL as source team
- Player team updates: Added update_player_team() method for immediate team assignments

Technical Changes:
- commands/transactions/ilmove.py: New command with organizational validation
- commands/transactions/__init__.py: Register ILMoveCommands cog
- services/transaction_service.py: create_transaction_batch() with correct batch format
- services/player_service.py: update_player_team() for immediate updates
- services/transaction_builder.py: RosterType affiliate resolution with async team lookups
- views/transaction_embed.py: Dual-mode support with context-aware instructions

Code Reuse:
- 95% code sharing between /dropadd and /ilmove via shared TransactionBuilder
- Same validation, UI, and move tracking - only submission differs
- Context-aware command_name parameter for dynamic UI instructions

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-20 20:15:12 -05:00

56 lines
1.8 KiB
Python

"""
Transaction command package for Discord Bot v2.0
Contains transaction management commands for league operations.
"""
import logging
from typing import List, Tuple, Type
import discord
from discord.ext import commands
from .management import TransactionCommands
from .dropadd import DropAddCommands
from .trade import TradeCommands
from .ilmove import ILMoveCommands
logger = logging.getLogger(f'{__name__}.setup_transactions')
async def setup_transactions(bot: commands.Bot) -> Tuple[int, int, List[str]]:
"""
Set up transaction command modules.
Returns:
Tuple of (successful_loads, failed_loads, failed_modules)
"""
transaction_cogs: List[Tuple[str, Type[commands.Cog]]] = [
("TransactionCommands", TransactionCommands),
("DropAddCommands", DropAddCommands),
("TradeCommands", TradeCommands),
("ILMoveCommands", ILMoveCommands),
]
successful = 0
failed = 0
failed_modules = []
for cog_name, cog_class in transaction_cogs:
try:
await bot.add_cog(cog_class(bot))
logger.info(f"✅ Loaded transaction command module: {cog_name}")
successful += 1
except Exception as e:
logger.error(f"❌ Failed to load transaction command module {cog_name}: {e}")
failed += 1
failed_modules.append(cog_name)
# Log summary
if failed == 0:
logger.info(f"🎉 All {successful} transaction command modules loaded successfully")
else:
logger.warning(f"⚠️ Transaction commands loaded with issues: {successful} successful, {failed} failed")
if failed_modules:
logger.warning(f"Failed modules: {', '.join(failed_modules)}")
return successful, failed, failed_modules