diff --git a/bot.py b/bot.py index 3febd33..ce43a0b 100644 --- a/bot.py +++ b/bot.py @@ -120,6 +120,7 @@ class SBABot(commands.Bot): from commands.help import setup_help_commands from commands.profile import setup_profile_commands from commands.soak import setup_soak + from commands.injuries import setup_injuries # Define command packages to load command_packages = [ @@ -135,6 +136,7 @@ class SBABot(commands.Bot): ("help", setup_help_commands), ("profile", setup_profile_commands), ("soak", setup_soak), + ("injuries", setup_injuries), ] total_successful = 0 diff --git a/commands/admin/management.py b/commands/admin/management.py index fcc9b1b..8791bd0 100644 --- a/commands/admin/management.py +++ b/commands/admin/management.py @@ -10,6 +10,7 @@ import discord from discord.ext import commands from discord import app_commands +from config import get_config from utils.logging import get_contextual_logger from utils.decorators import logged_command from views.embeds import EmbedColors, EmbedTemplate @@ -388,5 +389,4 @@ class AdminCommands(commands.Cog): async def setup(bot: commands.Bot): """Load the admin commands cog.""" -from config import get_config await bot.add_cog(AdminCommands(bot)) \ No newline at end of file diff --git a/commands/dice/rolls.py b/commands/dice/rolls.py index 840a751..e51e5da 100644 --- a/commands/dice/rolls.py +++ b/commands/dice/rolls.py @@ -99,7 +99,7 @@ class DiceRollCommands(commands.Cog): roll_results = self._parse_and_roll_multiple_dice(dice_notation) # Create embed for the roll results - embed = self._create_multi_roll_embed(dice_notation, roll_results, interaction.user) + embed = self._create_multi_roll_embed(dice_notation, roll_results, interaction.user, set_author=False) embed.title = f'At bat roll for {interaction.user.display_name}' await interaction.followup.send(embed=embed) @@ -146,8 +146,8 @@ class DiceRollCommands(commands.Cog): roll_results = self._roll_weighted_scout_dice(card_type_value) # Create embed for the roll results - embed = self._create_multi_roll_embed("1d6;2d6;1d20", roll_results, interaction.user) - embed.title = f'Scouting roll for {interaction.user.display_name} ({card_type.name})' + embed = self._create_multi_roll_embed("1d6;2d6;1d20", roll_results, interaction.user, set_author=False) + embed.title = f'Scouting roll for {interaction.user.display_name}' await interaction.followup.send(embed=embed) @discord.app_commands.command( @@ -416,7 +416,7 @@ class DiceRollCommands(commands.Cog): 14: '2-base error for e28 -> e31, e34, e35, e50\n1-base error for e14, e16, e19, e20, e22, e32, e39, e44, e56, e62', 13: '2-base error for e41, e47, e53, e59\n1-base error for e10, e15, e23, e25, e28, e30, e32, e33, e35, e44, e65', 12: '2-base error for e62\n1-base error for e12, e17, e22, e24, e27, e29, e34 -> e50, e56 -> e59, e65', - 11: '2-base error for e56, e65\n1-base error for e13, e18, e20, e21, e23, e26, e28, e31 -> e33, e35, e37, e41 -> e53, e59, e65', + 11: '2-base error for e56, e65\n1-base error for e13, e18, e20, e21, e23, e26, e28, e31 -> e33, e35, e37, e41 -> e53, e59', 10: '1-base error for e26, e31, e41, e53 -> 65', 9: '1-base error for e24, e27, e29, e34, e37, e39, e47 -> e65', 8: '1-base error for e25, e30, e33, e47, e53, e56, e62, e65', @@ -637,18 +637,19 @@ class DiceRollCommands(commands.Cog): return [first_d6_result, second_result, third_result] - def _create_multi_roll_embed(self, dice_notation: str, roll_results: list[DiceRoll], user: discord.User | discord.Member) -> discord.Embed: + def _create_multi_roll_embed(self, dice_notation: str, roll_results: list[DiceRoll], user: discord.User | discord.Member, set_author: bool = True) -> discord.Embed: """Create an embed for multiple dice roll results.""" embed = EmbedTemplate.create_base_embed( title="🎲 Dice Roll", color=EmbedColors.PRIMARY ) - # Set user info - embed.set_author( - name=user.display_name, - icon_url=user.display_avatar.url - ) + if set_author: + # Set user info + embed.set_author( + name=user.name, + icon_url=user.display_avatar.url + ) # Create summary line with totals totals = [str(result.total) for result in roll_results] diff --git a/commands/examples/enhanced_player.py b/commands/examples/enhanced_player.py index cf836b9..71be33f 100644 --- a/commands/examples/enhanced_player.py +++ b/commands/examples/enhanced_player.py @@ -9,6 +9,7 @@ from typing import Optional, List import discord from discord.ext import commands +from config import get_config from services.player_service import player_service from models.player import Player from utils.logging import get_contextual_logger @@ -329,7 +330,6 @@ class EnhancedPlayerCommands(commands.Cog): @logged_command("/player-search-modal") async def player_search_modal(self, interaction: discord.Interaction): """Demonstrate modal-based player search.""" -from config import get_config modal = PlayerSearchModal() await interaction.response.send_modal(modal) diff --git a/commands/examples/migration_example.py b/commands/examples/migration_example.py index 28e8d81..a0c0a45 100644 --- a/commands/examples/migration_example.py +++ b/commands/examples/migration_example.py @@ -9,6 +9,7 @@ from typing import Optional, List import discord from discord.ext import commands +from config import get_config from services.team_service import team_service from models.team import Team from utils.logging import get_contextual_logger @@ -307,5 +308,4 @@ class MigrationExampleCommands(commands.Cog): async def setup(bot: commands.Bot): """Load the migration example commands cog.""" -from config import get_config await bot.add_cog(MigrationExampleCommands(bot)) \ No newline at end of file diff --git a/commands/help/main.py b/commands/help/main.py index c8f6858..64e1e85 100644 --- a/commands/help/main.py +++ b/commands/help/main.py @@ -8,6 +8,7 @@ import discord from discord import app_commands from discord.ext import commands +from config import get_config from services.help_commands_service import ( help_commands_service, HelpCommandNotFoundError, @@ -368,7 +369,6 @@ class HelpCommands(commands.Cog): show_deleted: bool = False ): """Browse all help topics with optional category filter.""" -from config import get_config await interaction.response.defer() try: diff --git a/commands/injuries/management.py b/commands/injuries/management.py index 948aaa6..6701d5e 100644 --- a/commands/injuries/management.py +++ b/commands/injuries/management.py @@ -153,10 +153,11 @@ class InjuryGroup(app_commands.Group): gif_search_text = ['well shit', 'well fuck', 'god dammit'] else: gif_search_text = ['bummer', 'well damn'] + if player.is_pitcher: + result_text += ' plus their current rest requirement' elif injury_result == 'REM': if player.is_pitcher: result_text = '**FATIGUED**' - embed.set_footer(text='For pitchers, add their current rest to the injury') else: result_text = "**REMAINDER OF GAME**" embed.color = discord.Color.gold() diff --git a/commands/league/schedule.py b/commands/league/schedule.py index 2f964af..5998d8e 100644 --- a/commands/league/schedule.py +++ b/commands/league/schedule.py @@ -9,6 +9,7 @@ import asyncio import discord from discord.ext import commands +from config import get_config from services.schedule_service import schedule_service from utils.logging import get_contextual_logger from utils.decorators import logged_command @@ -349,5 +350,4 @@ class ScheduleCommands(commands.Cog): async def setup(bot: commands.Bot): """Load the schedule commands cog.""" -from config import get_config await bot.add_cog(ScheduleCommands(bot)) \ No newline at end of file diff --git a/commands/league/standings.py b/commands/league/standings.py index f3a59f7..e8401e0 100644 --- a/commands/league/standings.py +++ b/commands/league/standings.py @@ -8,6 +8,7 @@ from typing import Optional import discord from discord.ext import commands +from config import get_config from services.standings_service import standings_service from utils.logging import get_contextual_logger from utils.decorators import logged_command @@ -249,5 +250,4 @@ class StandingsCommands(commands.Cog): async def setup(bot: commands.Bot): """Load the standings commands cog.""" -from config import get_config await bot.add_cog(StandingsCommands(bot)) \ No newline at end of file diff --git a/commands/league/submit_scorecard.py b/commands/league/submit_scorecard.py index ffc058b..ef2aefb 100644 --- a/commands/league/submit_scorecard.py +++ b/commands/league/submit_scorecard.py @@ -23,10 +23,7 @@ from utils.discord_helpers import send_to_channel, format_key_plays from utils.team_utils import get_user_major_league_team from views.embeds import EmbedTemplate from views.confirmations import ConfirmationView -from constants import ( - SBA_NETWORK_NEWS_CHANNEL, - SBA_PLAYERS_ROLE_NAME -) +from config import get_config from exceptions import SheetsException, APIException from models.team import Team from models.player import Player @@ -50,7 +47,7 @@ class SubmitScorecardCommands(commands.Cog): @app_commands.describe( sheet_url="Full URL to the Google Sheets scorecard" ) - @app_commands.checks.has_any_role(SBA_PLAYERS_ROLE_NAME) + @app_commands.checks.has_any_role(get_config().sba_players_role_name) @logged_command("/submit-scorecard") async def submit_scorecard( self, @@ -357,7 +354,7 @@ class SubmitScorecardCommands(commands.Cog): # Phase 13: Post to News Channel await send_to_channel( self.bot, - SBA_NETWORK_NEWS_CHANNEL, + get_config().sba_network_news_channel, content=None, embed=results_embed ) diff --git a/commands/players/info.py b/commands/players/info.py index aebf542..4036390 100644 --- a/commands/players/info.py +++ b/commands/players/info.py @@ -8,6 +8,8 @@ from typing import Optional, List import discord from discord.ext import commands +from config import get_config + from services.player_service import player_service from services.stats_service import stats_service from utils.logging import get_contextual_logger @@ -172,7 +174,6 @@ class PlayerInfoCommands(commands.Cog): pitching_stats=None ) -> discord.Embed: """Create a comprehensive player embed with statistics.""" -from config import get_config # Determine embed color based on team embed_color = EmbedColors.PRIMARY if hasattr(player, 'team') and player.team and hasattr(player.team, 'color'): diff --git a/commands/profile/images.py b/commands/profile/images.py index 4f590cb..87f98aa 100644 --- a/commands/profile/images.py +++ b/commands/profile/images.py @@ -12,6 +12,7 @@ import discord from discord import app_commands from discord.ext import commands +from config import get_config from services.player_service import player_service from services.team_service import team_service from utils.logging import get_contextual_logger @@ -229,7 +230,6 @@ class ImageCommands(commands.Cog): image_url: str ): """Update a player's image (fancy card or headshot).""" -from config import get_config # Defer response for potentially slow operations await interaction.response.defer(ephemeral=True) diff --git a/commands/teams/info.py b/commands/teams/info.py index e342d79..1c0a97d 100644 --- a/commands/teams/info.py +++ b/commands/teams/info.py @@ -3,6 +3,7 @@ Team information commands for Discord Bot v2.0 """ import logging from typing import Optional +from config import get_config import discord from discord.ext import commands @@ -128,7 +129,6 @@ class TeamInfoCommands(commands.Cog): async def _create_team_embed(self, team: Team, standings_data: Optional[dict] = None) -> discord.Embed: """Create a rich embed for team information.""" -from config import get_config embed = EmbedTemplate.create_base_embed( title=f"{team.abbrev} - {team.lname}", description=f"Season {team.season} Team Information", diff --git a/commands/teams/roster.py b/commands/teams/roster.py index e8e0814..261cce8 100644 --- a/commands/teams/roster.py +++ b/commands/teams/roster.py @@ -7,6 +7,7 @@ from typing import Optional, Dict, Any, List import discord from discord.ext import commands +from config import get_config from models.player import Player from services import team_service, player_service from models.team import Team @@ -140,7 +141,6 @@ class TeamRosterCommands(commands.Cog): def _create_player_list_embed(self, team: Team, roster_name: str, players: List[Dict[str, Any]]) -> discord.Embed: """Create an embed with detailed player list.""" -from config import get_config roster_titles = { 'active': 'Active Roster', 'longil': 'Minor League', diff --git a/commands/transactions/dropadd.py b/commands/transactions/dropadd.py index 5a5096e..239494e 100644 --- a/commands/transactions/dropadd.py +++ b/commands/transactions/dropadd.py @@ -9,6 +9,7 @@ import discord from discord.ext import commands from discord import app_commands +from config import get_config from utils.logging import get_contextual_logger from utils.decorators import logged_command from utils.autocomplete import player_autocomplete @@ -231,5 +232,4 @@ class DropAddCommands(commands.Cog): async def setup(bot): """Setup function for the cog.""" -from config import get_config await bot.add_cog(DropAddCommands(bot)) \ No newline at end of file diff --git a/commands/transactions/management.py b/commands/transactions/management.py index 1aab9ff..9d37d36 100644 --- a/commands/transactions/management.py +++ b/commands/transactions/management.py @@ -10,6 +10,7 @@ import discord from discord.ext import commands from discord import app_commands +from config import get_config from utils.logging import get_contextual_logger from utils.decorators import logged_command from utils.team_utils import get_user_major_league_team @@ -520,5 +521,4 @@ class TransactionCommands(commands.Cog): async def setup(bot: commands.Bot): """Load the transaction commands cog.""" -from config import get_config await bot.add_cog(TransactionCommands(bot)) \ No newline at end of file diff --git a/commands/transactions/trade.py b/commands/transactions/trade.py index f381ab6..0dea66e 100644 --- a/commands/transactions/trade.py +++ b/commands/transactions/trade.py @@ -9,6 +9,7 @@ import discord from discord.ext import commands from discord import app_commands +from config import get_config from utils.logging import get_contextual_logger from utils.decorators import logged_command from utils.autocomplete import player_autocomplete, major_league_team_autocomplete, team_autocomplete @@ -531,5 +532,4 @@ class TradeCommands(commands.Cog): async def setup(bot): """Setup function for the cog.""" -from config import get_config await bot.add_cog(TradeCommands(bot)) \ No newline at end of file diff --git a/commands/utilities/charts.py b/commands/utilities/charts.py index 3053f5b..8d942db 100644 --- a/commands/utilities/charts.py +++ b/commands/utilities/charts.py @@ -9,6 +9,7 @@ from discord import app_commands from discord.ext import commands from typing import List, Optional +from config import get_config from utils.decorators import logged_command from utils.logging import get_contextual_logger, set_discord_context from services.chart_service import get_chart_service, Chart @@ -633,7 +634,6 @@ class ChartCategoryGroup(app_commands.Group): async def setup(bot: commands.Bot): """Setup function for chart commands.""" -from config import get_config await bot.add_cog(ChartCommands(bot)) bot.tree.add_command(ChartManageGroup()) bot.tree.add_command(ChartCategoryGroup()) diff --git a/commands/voice/channels.py b/commands/voice/channels.py index 9c3257e..6e9c0ac 100644 --- a/commands/voice/channels.py +++ b/commands/voice/channels.py @@ -10,6 +10,7 @@ from typing import Optional import discord from discord.ext import commands +from config import get_config from services.team_service import team_service from services.schedule_service import ScheduleService from services.league_service import league_service @@ -351,7 +352,6 @@ class VoiceChannelCommands(commands.Cog): @commands.command(name="private") async def deprecated_private_voice(self, ctx: commands.Context): """Deprecated command - redirect to new slash command.""" -from config import get_config embed = EmbedTemplate.info( title="Command Deprecated", description=( diff --git a/services/league_service.py b/services/league_service.py index cce1015..35545d2 100644 --- a/services/league_service.py +++ b/services/league_service.py @@ -6,6 +6,7 @@ Handles league-wide operations including current state, standings, and season in import logging from typing import Optional, List, Dict, Any +from config import get_config from services.base_service import BaseService from models.current import Current from exceptions import APIException @@ -112,7 +113,6 @@ class LeagueService(BaseService[Current]): async def get_league_leaders(self, stat_type: str = 'batting', season: Optional[int] = None, limit: int = 10) -> Optional[List[Dict[str, Any]]]: """ -from config import get_config Get league leaders for a specific statistic category. Args: diff --git a/services/player_service.py b/services/player_service.py index 4022485..c20e04a 100644 --- a/services/player_service.py +++ b/services/player_service.py @@ -6,6 +6,7 @@ Handles player-related operations with team population and search functionality. import logging from typing import Optional, List, TYPE_CHECKING +from config import get_config from services.base_service import BaseService from models.player import Player from exceptions import APIException @@ -191,7 +192,7 @@ class PlayerService(BaseService[Player]): """ try: if season is None: - season = get_config().sba_current_season + season = get_config().sba_current_season # Use the existing name-based search that actually works players = await self.get_players_by_name(query, season) @@ -278,7 +279,6 @@ class PlayerService(BaseService[Player]): async def update_player(self, player_id: int, updates: dict) -> Optional[Player]: """ -from config import get_config Update player information. Args: diff --git a/services/team_service.py b/services/team_service.py index 68a80a9..3927faf 100644 --- a/services/team_service.py +++ b/services/team_service.py @@ -6,6 +6,7 @@ Handles team-related operations with roster management and league queries. import logging from typing import Optional, List, Dict, Any +from config import get_config from services.base_service import BaseService from models.team import Team, RosterType from exceptions import APIException @@ -299,7 +300,6 @@ class TeamService(BaseService[Team]): async def get_current_season_teams(self) -> List[Team]: """ -from config import get_config Get all teams for the current season. Returns: diff --git a/services/trade_builder.py b/services/trade_builder.py index e7a9588..bf3014a 100644 --- a/services/trade_builder.py +++ b/services/trade_builder.py @@ -8,6 +8,7 @@ from typing import Dict, List, Optional, Tuple from datetime import datetime, timezone import uuid +from config import get_config from models.trade import Trade, TradeParticipant, TradeMove, TradeStatus from models.team import Team, RosterType from models.player import Player @@ -466,7 +467,6 @@ def get_trade_builder(user_id: int, initiating_team: Team) -> TradeBuilder: def clear_trade_builder(user_id: int) -> None: """Clear trade builder for a user.""" -from config import get_config trade_key = f"{user_id}:trade" if trade_key in _active_trade_builders: del _active_trade_builders[trade_key] diff --git a/services/transaction_builder.py b/services/transaction_builder.py index 9d812f2..0b4a830 100644 --- a/services/transaction_builder.py +++ b/services/transaction_builder.py @@ -9,6 +9,7 @@ from enum import Enum from dataclasses import dataclass from datetime import datetime, timezone +from config import get_config from models.transaction import Transaction from models.team import Team from models.player import Player @@ -522,7 +523,6 @@ def get_transaction_builder(user_id: int, team: Team) -> TransactionBuilder: def clear_transaction_builder(user_id: int) -> None: """Clear transaction builder for a user.""" -from config import get_config if user_id in _active_builders: del _active_builders[user_id] logger.info(f"Cleared transaction builder for user {user_id}") \ No newline at end of file diff --git a/test_real_data.py b/test_real_data.py index a7c4dc4..bbf66b5 100644 --- a/test_real_data.py +++ b/test_real_data.py @@ -19,6 +19,7 @@ os.environ.setdefault('LOG_LEVEL', 'DEBUG') os.environ.setdefault('ENVIRONMENT', 'testing') os.environ.setdefault('TESTING', 'true') +from config import get_config from services.player_service import player_service from utils.logging import get_contextual_logger, set_discord_context from api.client import cleanup_global_client diff --git a/utils/autocomplete.py b/utils/autocomplete.py index dd8e08e..a5ea14b 100644 --- a/utils/autocomplete.py +++ b/utils/autocomplete.py @@ -7,6 +7,7 @@ from typing import List, Optional import discord from discord import app_commands +from config import get_config from services.player_service import player_service from services.team_service import team_service from utils.team_utils import get_user_major_league_team @@ -149,7 +150,6 @@ async def major_league_team_autocomplete( # Filter to only Major League teams using the model's helper method from models.team import RosterType -from config import get_config ml_teams = [ team for team in all_teams if team.roster_type() == RosterType.MAJOR_LEAGUE diff --git a/utils/team_utils.py b/utils/team_utils.py index 6a3f4f7..3b8ff81 100644 --- a/utils/team_utils.py +++ b/utils/team_utils.py @@ -8,6 +8,7 @@ import discord from models.team import Team from services.team_service import team_service +from config import get_config async def get_user_major_league_team( @@ -88,7 +89,6 @@ async def get_team_by_abbrev_with_validation( Returns: Team object if found, None if not (error message already sent) """ -from config import get_config try: team = await team_service.get_team_by_abbrev(team_abbrev, season) diff --git a/views/embeds.py b/views/embeds.py index e6779e0..ec5c0b6 100644 --- a/views/embeds.py +++ b/views/embeds.py @@ -7,6 +7,8 @@ from typing import Optional, Union, Any, List from datetime import datetime from dataclasses import dataclass +from config import get_config + import discord @@ -384,7 +386,6 @@ class EmbedBuilder: def author(self, name: str, url: Optional[str] = None, icon_url: Optional[str] = None) -> 'EmbedBuilder': """Set embed author.""" -from config import get_config self._embed.set_author(name=name, url=url, icon_url=icon_url) return self