major-domo-v2/commands/transactions/__init__.py
Cal Corum 758be0f166 CLAUDE: Fix trade system issues and enhance documentation
Major fixes and improvements:

Trade System Fixes:
- Fix duplicate player moves in trade embed Player Exchanges section
- Resolve "WVMiL not participating" error for Minor League destinations
- Implement organizational authority model for ML/MiL/IL team relationships
- Update Trade.cross_team_moves to deduplicate using moves_giving only

Team Model Enhancements:
- Rewrite roster_type() method using sname as definitive source per spec
- Fix edge cases like "BHMIL" (Birmingham IL) vs "BHMMIL"
- Update _get_base_abbrev() to use consistent sname-based logic
- Add organizational lookup support in trade participation

Autocomplete System:
- Fix major_league_team_autocomplete invalid roster_type parameter
- Implement client-side filtering using Team.roster_type() method
- Add comprehensive test coverage for all autocomplete functions
- Centralize autocomplete logic to shared utils functions

Test Infrastructure:
- Add 25 new tests for trade models and trade builder
- Add 13 autocomplete function tests with error handling
- Fix existing test failures with proper mocking patterns
- Update dropadd tests to use shared autocomplete functions

Documentation Updates:
- Document trade model enhancements and deduplication fix
- Add autocomplete function documentation with usage examples
- Document organizational authority model and edge case handling
- Update README files with recent fixes and implementation notes

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

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

54 lines
1.7 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
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),
]
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