Consolidate season config variables to single source (v2.21.0)
Remove redundant sba_current_season and pd_current_season config values. All code now uses sba_season and pd_season, which properly read from environment variables. Fixes /team command defaulting to Season 12. - Remove duplicate *_current_season constants from config.py - Update 100+ references across commands, services, and utils - sba_season defaults to 13, pd_season defaults to 10 - Environment variables SBA_SEASON/PD_SEASON now work correctly 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5133dc3d0f
commit
1d6fef51ab
@ -85,7 +85,7 @@ class AdminCommands(commands.Cog):
|
||||
name="Bot Information",
|
||||
value=f"**Latency:** {round(self.bot.latency * 1000)}ms\n"
|
||||
f"**Version:** Discord.py {discord.__version__}\n"
|
||||
f"**Current Season:** {get_config().sba_current_season}",
|
||||
f"**Current Season:** {get_config().sba_season}",
|
||||
inline=True
|
||||
)
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ class DraftAdminGroup(app_commands.Group):
|
||||
# Get current pick
|
||||
config = get_config()
|
||||
current_pick = await draft_pick_service.get_pick(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
draft_data.currentpick
|
||||
)
|
||||
|
||||
@ -142,7 +142,7 @@ class DraftAdminGroup(app_commands.Group):
|
||||
return
|
||||
|
||||
# Verify pick exists
|
||||
pick = await draft_pick_service.get_pick(config.sba_current_season, pick_number)
|
||||
pick = await draft_pick_service.get_pick(config.sba_season, pick_number)
|
||||
if not pick:
|
||||
embed = EmbedTemplate.error(
|
||||
"Pick Not Found",
|
||||
|
||||
@ -58,7 +58,7 @@ class DraftBoardCommands(commands.Cog):
|
||||
|
||||
# Get picks for this round
|
||||
picks = await draft_pick_service.get_picks_by_round(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
round_number,
|
||||
include_taken=True
|
||||
)
|
||||
|
||||
@ -33,7 +33,7 @@ async def fa_player_autocomplete(
|
||||
players = await player_service.search_players(
|
||||
current,
|
||||
limit=25,
|
||||
season=config.sba_current_season
|
||||
season=config.sba_season
|
||||
)
|
||||
|
||||
# Filter to FA team
|
||||
@ -74,7 +74,7 @@ class DraftListCommands(commands.Cog):
|
||||
# Get user's team
|
||||
team = await team_service.get_team_by_owner(
|
||||
interaction.user.id,
|
||||
config.sba_current_season
|
||||
config.sba_season
|
||||
)
|
||||
|
||||
if not team:
|
||||
@ -87,7 +87,7 @@ class DraftListCommands(commands.Cog):
|
||||
|
||||
# Get draft list
|
||||
draft_list = await draft_list_service.get_team_list(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
team.id
|
||||
)
|
||||
|
||||
@ -121,7 +121,7 @@ class DraftListCommands(commands.Cog):
|
||||
# Get user's team
|
||||
team = await team_service.get_team_by_owner(
|
||||
interaction.user.id,
|
||||
config.sba_current_season
|
||||
config.sba_season
|
||||
)
|
||||
|
||||
if not team:
|
||||
@ -133,7 +133,7 @@ class DraftListCommands(commands.Cog):
|
||||
return
|
||||
|
||||
# Get player
|
||||
players = await player_service.get_players_by_name(player, config.sba_current_season)
|
||||
players = await player_service.get_players_by_name(player, config.sba_season)
|
||||
if not players:
|
||||
embed = EmbedTemplate.error(
|
||||
"Player Not Found",
|
||||
@ -155,7 +155,7 @@ class DraftListCommands(commands.Cog):
|
||||
|
||||
# Check if player already in list
|
||||
current_list = await draft_list_service.get_team_list(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
team.id
|
||||
)
|
||||
|
||||
@ -179,7 +179,7 @@ class DraftListCommands(commands.Cog):
|
||||
|
||||
# Add to list
|
||||
updated_list = await draft_list_service.add_to_list(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
team.id,
|
||||
player_obj.id,
|
||||
rank
|
||||
@ -228,7 +228,7 @@ class DraftListCommands(commands.Cog):
|
||||
# Get user's team
|
||||
team = await team_service.get_team_by_owner(
|
||||
interaction.user.id,
|
||||
config.sba_current_season
|
||||
config.sba_season
|
||||
)
|
||||
|
||||
if not team:
|
||||
@ -240,7 +240,7 @@ class DraftListCommands(commands.Cog):
|
||||
return
|
||||
|
||||
# Get player
|
||||
players = await player_service.get_players_by_name(player, config.sba_current_season)
|
||||
players = await player_service.get_players_by_name(player, config.sba_season)
|
||||
if not players:
|
||||
embed = EmbedTemplate.error(
|
||||
"Player Not Found",
|
||||
@ -253,7 +253,7 @@ class DraftListCommands(commands.Cog):
|
||||
|
||||
# Remove from list
|
||||
success = await draft_list_service.remove_player_from_list(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
team.id,
|
||||
player_obj.id
|
||||
)
|
||||
@ -287,7 +287,7 @@ class DraftListCommands(commands.Cog):
|
||||
# Get user's team
|
||||
team = await team_service.get_team_by_owner(
|
||||
interaction.user.id,
|
||||
config.sba_current_season
|
||||
config.sba_season
|
||||
)
|
||||
|
||||
if not team:
|
||||
@ -300,7 +300,7 @@ class DraftListCommands(commands.Cog):
|
||||
|
||||
# Get current list size
|
||||
current_list = await draft_list_service.get_team_list(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
team.id
|
||||
)
|
||||
|
||||
@ -314,7 +314,7 @@ class DraftListCommands(commands.Cog):
|
||||
|
||||
# Clear list
|
||||
success = await draft_list_service.clear_list(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
team.id
|
||||
)
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ async def fa_player_autocomplete(
|
||||
players = await player_service.search_players(
|
||||
current,
|
||||
limit=25,
|
||||
season=config.sba_current_season
|
||||
season=config.sba_season
|
||||
)
|
||||
|
||||
# Filter to FA team
|
||||
@ -138,7 +138,7 @@ class DraftPicksCog(commands.Cog):
|
||||
# Get user's team (CACHED via @cached_single_item)
|
||||
team = await team_service.get_team_by_owner(
|
||||
interaction.user.id,
|
||||
config.sba_current_season
|
||||
config.sba_season
|
||||
)
|
||||
|
||||
if not team:
|
||||
@ -161,7 +161,7 @@ class DraftPicksCog(commands.Cog):
|
||||
|
||||
# Get current pick
|
||||
current_pick = await draft_pick_service.get_pick(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
draft_data.currentpick
|
||||
)
|
||||
|
||||
@ -184,7 +184,7 @@ class DraftPicksCog(commands.Cog):
|
||||
return
|
||||
|
||||
# Get player
|
||||
players = await player_service.get_players_by_name(player_name, config.sba_current_season)
|
||||
players = await player_service.get_players_by_name(player_name, config.sba_season)
|
||||
|
||||
if not players:
|
||||
embed = await create_pick_illegal_embed(
|
||||
|
||||
@ -47,7 +47,7 @@ class DraftStatusCommands(commands.Cog):
|
||||
|
||||
# Get current pick
|
||||
current_pick = await draft_pick_service.get_pick(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
draft_data.currentpick
|
||||
)
|
||||
|
||||
@ -99,7 +99,7 @@ class DraftStatusCommands(commands.Cog):
|
||||
|
||||
# Get current pick
|
||||
current_pick = await draft_pick_service.get_pick(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
draft_data.currentpick
|
||||
)
|
||||
|
||||
@ -113,14 +113,14 @@ class DraftStatusCommands(commands.Cog):
|
||||
|
||||
# Get recent picks
|
||||
recent_picks = await draft_pick_service.get_recent_picks(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
draft_data.currentpick,
|
||||
limit=5
|
||||
)
|
||||
|
||||
# Get upcoming picks
|
||||
upcoming_picks = await draft_pick_service.get_upcoming_picks(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
draft_data.currentpick,
|
||||
limit=5
|
||||
)
|
||||
|
||||
@ -71,7 +71,7 @@ class EnhancedPlayerCommands(commands.Cog):
|
||||
return
|
||||
|
||||
# Use current season if not specified
|
||||
search_season = season or get_config().sba_current_season
|
||||
search_season = season or get_config().sba_season
|
||||
|
||||
# Search for players
|
||||
players = await player_service.get_players_by_name(name, search_season)
|
||||
@ -342,7 +342,7 @@ class EnhancedPlayerCommands(commands.Cog):
|
||||
# Perform search based on criteria
|
||||
players = await player_service.get_players_by_name(
|
||||
search_criteria['name'],
|
||||
search_criteria['season'] or get_config().sba_current_season
|
||||
search_criteria['season'] or get_config().sba_season
|
||||
)
|
||||
|
||||
if players:
|
||||
@ -351,13 +351,13 @@ class EnhancedPlayerCommands(commands.Cog):
|
||||
await self._show_player_details(
|
||||
interaction,
|
||||
players[0],
|
||||
search_criteria['season'] or get_config().sba_current_season
|
||||
search_criteria['season'] or get_config().sba_season
|
||||
)
|
||||
else:
|
||||
await self._show_player_selection(
|
||||
interaction,
|
||||
players,
|
||||
search_criteria['season'] or get_config().sba_current_season
|
||||
search_criteria['season'] or get_config().sba_season
|
||||
)
|
||||
else:
|
||||
embed = EmbedTemplate.warning(
|
||||
|
||||
@ -48,7 +48,7 @@ class MigrationExampleCommands(commands.Cog):
|
||||
"""Old style team listing - basic embed only."""
|
||||
await interaction.response.defer()
|
||||
|
||||
season = season or get_config().sba_current_season
|
||||
season = season or get_config().sba_season
|
||||
teams = await team_service.get_teams_by_season(season)
|
||||
|
||||
if not teams:
|
||||
@ -91,7 +91,7 @@ class MigrationExampleCommands(commands.Cog):
|
||||
"""New style team listing - interactive with pagination and selection."""
|
||||
await interaction.response.defer()
|
||||
|
||||
season = season or get_config().sba_current_season
|
||||
season = season or get_config().sba_season
|
||||
teams = await team_service.get_teams_by_season(season)
|
||||
|
||||
if not teams:
|
||||
|
||||
@ -45,7 +45,7 @@ class ScheduleCommands(commands.Cog):
|
||||
"""Display game schedule for a week or team."""
|
||||
await interaction.response.defer()
|
||||
|
||||
search_season = season or get_config().sba_current_season
|
||||
search_season = season or get_config().sba_season
|
||||
|
||||
if team:
|
||||
# Show team schedule
|
||||
@ -75,7 +75,7 @@ class ScheduleCommands(commands.Cog):
|
||||
# """Display recent game results."""
|
||||
# await interaction.response.defer()
|
||||
|
||||
# search_season = season or get_config().sba_current_season
|
||||
# search_season = season or get_config().sba_season
|
||||
|
||||
# if week:
|
||||
# # Show specific week results
|
||||
|
||||
@ -43,7 +43,7 @@ class StandingsCommands(commands.Cog):
|
||||
"""Display league standings by division."""
|
||||
await interaction.response.defer()
|
||||
|
||||
search_season = season or get_config().sba_current_season
|
||||
search_season = season or get_config().sba_season
|
||||
|
||||
if division:
|
||||
# Show specific division
|
||||
@ -69,7 +69,7 @@ class StandingsCommands(commands.Cog):
|
||||
"""Display playoff picture with division leaders and wild card race."""
|
||||
await interaction.response.defer()
|
||||
|
||||
search_season = season or get_config().sba_current_season
|
||||
search_season = season or get_config().sba_season
|
||||
self.logger.debug("Fetching playoff picture", season=search_season)
|
||||
|
||||
playoff_data = await standings_service.get_playoff_picture(search_season)
|
||||
|
||||
@ -27,7 +27,7 @@ async def player_name_autocomplete(
|
||||
|
||||
try:
|
||||
# Use the dedicated search endpoint to get matching players
|
||||
players = await player_service.search_players(current, limit=25, season=get_config().sba_current_season)
|
||||
players = await player_service.search_players(current, limit=25, season=get_config().sba_season)
|
||||
|
||||
# Convert to discord choices, limiting to 25 (Discord's max)
|
||||
choices = []
|
||||
@ -78,7 +78,7 @@ class PlayerInfoCommands(commands.Cog):
|
||||
self.logger.debug("Response deferred")
|
||||
|
||||
# Search for player by name (use season parameter or default to current)
|
||||
search_season = season or get_config().sba_current_season
|
||||
search_season = season or get_config().sba_season
|
||||
self.logger.debug("Starting player search", api_call="get_players_by_name", season=search_season)
|
||||
players = await player_service.get_players_by_name(name, search_season)
|
||||
self.logger.info("Player search completed", players_found=len(players), season=search_season)
|
||||
|
||||
@ -279,7 +279,7 @@ class ImageCommands(commands.Cog):
|
||||
|
||||
# Step 3: Find player
|
||||
self.logger.debug("Searching for player", player_name=player_name)
|
||||
players = await player_service.get_players_by_name(player_name, get_config().sba_current_season)
|
||||
players = await player_service.get_players_by_name(player_name, get_config().sba_season)
|
||||
|
||||
if not players:
|
||||
self.logger.warning("Player not found", player_name=player_name)
|
||||
@ -316,7 +316,7 @@ class ImageCommands(commands.Cog):
|
||||
|
||||
# Step 4: Check permissions
|
||||
has_permission, permission_error = await can_edit_player_image(
|
||||
interaction, player, get_config().sba_current_season, self.logger
|
||||
interaction, player, get_config().sba_season, self.logger
|
||||
)
|
||||
|
||||
if not has_permission:
|
||||
|
||||
@ -17,6 +17,7 @@ from services import team_service
|
||||
from models.team import Team
|
||||
from utils.logging import get_contextual_logger
|
||||
from utils.decorators import logged_command
|
||||
from utils.permissions import league_only
|
||||
from views.embeds import EmbedTemplate, EmbedColors
|
||||
from views.confirmations import ConfirmationView
|
||||
|
||||
@ -217,6 +218,7 @@ class BrandingCommands(commands.Cog):
|
||||
self.logger.info("BrandingCommands cog initialized")
|
||||
|
||||
@app_commands.command(name="branding", description="Update your team's colors and logos")
|
||||
@league_only()
|
||||
@logged_command("/branding")
|
||||
async def team_branding(self, interaction: discord.Interaction):
|
||||
"""
|
||||
@ -229,7 +231,7 @@ class BrandingCommands(commands.Cog):
|
||||
"""
|
||||
# Get current season
|
||||
config = get_config()
|
||||
season = config.sba_current_season
|
||||
season = config.sba_season
|
||||
|
||||
# Verify user owns a team (must do this BEFORE responding to interaction)
|
||||
ml_team = await team_service.get_team_by_owner(interaction.user.id, season)
|
||||
|
||||
@ -36,7 +36,7 @@ class TeamInfoCommands(commands.Cog):
|
||||
await interaction.response.defer()
|
||||
|
||||
# Use current season if not specified
|
||||
season = season or get_config().sba_current_season
|
||||
season = season or get_config().sba_season
|
||||
|
||||
# Get team by abbreviation
|
||||
team = await team_service.get_team_by_abbrev(abbrev, season)
|
||||
@ -67,7 +67,7 @@ class TeamInfoCommands(commands.Cog):
|
||||
"""List all teams in a season."""
|
||||
await interaction.response.defer()
|
||||
|
||||
season = season or get_config().sba_current_season
|
||||
season = season or get_config().sba_season
|
||||
|
||||
teams = await team_service.get_teams_by_season(season)
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ class TeamRosterCommands(commands.Cog):
|
||||
await interaction.response.defer()
|
||||
|
||||
# Get team by abbreviation
|
||||
team = await team_service.get_team_by_abbrev(abbrev, get_config().sba_current_season)
|
||||
team = await team_service.get_team_by_abbrev(abbrev, get_config().sba_season)
|
||||
|
||||
if team is None:
|
||||
self.logger.info("Team not found", team_abbrev=abbrev)
|
||||
|
||||
@ -129,7 +129,7 @@ class DropAddCommands(commands.Cog):
|
||||
"""
|
||||
try:
|
||||
# Find player using the new search endpoint
|
||||
players = await player_service.search_players(player_name, limit=10, season=get_config().sba_current_season)
|
||||
players = await player_service.search_players(player_name, limit=10, season=get_config().sba_season)
|
||||
if not players:
|
||||
self.logger.error(f"Player not found: {player_name}")
|
||||
return False, f"Player '{player_name}' not found"
|
||||
|
||||
@ -134,7 +134,7 @@ class ILMoveCommands(commands.Cog):
|
||||
"""
|
||||
try:
|
||||
# Find player using the new search endpoint
|
||||
players = await player_service.search_players(player_name, limit=10, season=get_config().sba_current_season)
|
||||
players = await player_service.search_players(player_name, limit=10, season=get_config().sba_season)
|
||||
if not players:
|
||||
self.logger.error(f"Player not found: {player_name}")
|
||||
return False, f"Player '{player_name}' not found"
|
||||
|
||||
@ -124,7 +124,7 @@ class TransactionCommands(commands.Cog):
|
||||
await interaction.response.defer()
|
||||
|
||||
# Get user's team
|
||||
team = await get_user_major_league_team(interaction.user.id, get_config().sba_current_season)
|
||||
team = await get_user_major_league_team(interaction.user.id, get_config().sba_season)
|
||||
|
||||
if not team:
|
||||
await interaction.followup.send(
|
||||
@ -134,9 +134,9 @@ class TransactionCommands(commands.Cog):
|
||||
return
|
||||
|
||||
# Get transactions in parallel
|
||||
pending_task = transaction_service.get_pending_transactions(team.abbrev, get_config().sba_current_season)
|
||||
frozen_task = transaction_service.get_frozen_transactions(team.abbrev, get_config().sba_current_season)
|
||||
processed_task = transaction_service.get_processed_transactions(team.abbrev, get_config().sba_current_season)
|
||||
pending_task = transaction_service.get_pending_transactions(team.abbrev, get_config().sba_season)
|
||||
frozen_task = transaction_service.get_frozen_transactions(team.abbrev, get_config().sba_season)
|
||||
processed_task = transaction_service.get_processed_transactions(team.abbrev, get_config().sba_season)
|
||||
|
||||
pending_transactions = await pending_task
|
||||
frozen_transactions = await frozen_task
|
||||
@ -147,7 +147,7 @@ class TransactionCommands(commands.Cog):
|
||||
if show_cancelled:
|
||||
cancelled_transactions = await transaction_service.get_team_transactions(
|
||||
team.abbrev,
|
||||
get_config().sba_current_season,
|
||||
get_config().sba_season,
|
||||
cancelled=True
|
||||
)
|
||||
|
||||
@ -200,16 +200,16 @@ class TransactionCommands(commands.Cog):
|
||||
|
||||
# Get target team
|
||||
if team:
|
||||
target_team = await team_service.get_team_by_abbrev(team.upper(), get_config().sba_current_season)
|
||||
target_team = await team_service.get_team_by_abbrev(team.upper(), get_config().sba_season)
|
||||
if not target_team:
|
||||
await interaction.followup.send(
|
||||
f"❌ Could not find team '{team}' in season {get_config().sba_current_season}.",
|
||||
f"❌ Could not find team '{team}' in season {get_config().sba_season}.",
|
||||
ephemeral=True
|
||||
)
|
||||
return
|
||||
else:
|
||||
# Get user's team
|
||||
user_teams = await team_service.get_teams_by_owner(interaction.user.id, get_config().sba_current_season)
|
||||
user_teams = await team_service.get_teams_by_owner(interaction.user.id, get_config().sba_season)
|
||||
if not user_teams:
|
||||
await interaction.followup.send(
|
||||
"❌ You don't appear to own a team. Please specify a team abbreviation.",
|
||||
@ -286,7 +286,7 @@ class TransactionCommands(commands.Cog):
|
||||
|
||||
embed = EmbedTemplate.create_base_embed(
|
||||
title=f"📋 Transaction Status - {team.abbrev}",
|
||||
description=f"{team.lname} • Season {get_config().sba_current_season}",
|
||||
description=f"{team.lname} • Season {get_config().sba_season}",
|
||||
color=EmbedColors.INFO
|
||||
)
|
||||
|
||||
@ -323,7 +323,7 @@ class TransactionCommands(commands.Cog):
|
||||
# No pending transactions - create single page
|
||||
embed = EmbedTemplate.create_base_embed(
|
||||
title=f"📋 Transaction Status - {team.abbrev}",
|
||||
description=f"{team.lname} • Season {get_config().sba_current_season}",
|
||||
description=f"{team.lname} • Season {get_config().sba_season}",
|
||||
color=EmbedColors.INFO
|
||||
)
|
||||
|
||||
@ -353,7 +353,7 @@ class TransactionCommands(commands.Cog):
|
||||
if frozen_transactions:
|
||||
embed = EmbedTemplate.create_base_embed(
|
||||
title=f"📋 Transaction Status - {team.abbrev}",
|
||||
description=f"{team.lname} • Season {get_config().sba_current_season}",
|
||||
description=f"{team.lname} • Season {get_config().sba_season}",
|
||||
color=EmbedColors.INFO
|
||||
)
|
||||
|
||||
@ -374,7 +374,7 @@ class TransactionCommands(commands.Cog):
|
||||
if processed_transactions:
|
||||
embed = EmbedTemplate.create_base_embed(
|
||||
title=f"📋 Transaction Status - {team.abbrev}",
|
||||
description=f"{team.lname} • Season {get_config().sba_current_season}",
|
||||
description=f"{team.lname} • Season {get_config().sba_season}",
|
||||
color=EmbedColors.INFO
|
||||
)
|
||||
|
||||
@ -395,7 +395,7 @@ class TransactionCommands(commands.Cog):
|
||||
if cancelled_transactions:
|
||||
embed = EmbedTemplate.create_base_embed(
|
||||
title=f"📋 Transaction Status - {team.abbrev}",
|
||||
description=f"{team.lname} • Season {get_config().sba_current_season}",
|
||||
description=f"{team.lname} • Season {get_config().sba_season}",
|
||||
color=EmbedColors.INFO
|
||||
)
|
||||
|
||||
@ -440,7 +440,7 @@ class TransactionCommands(commands.Cog):
|
||||
|
||||
embed = EmbedTemplate.create_base_embed(
|
||||
title=f"{status_emoji} Roster Check - {team.abbrev}",
|
||||
description=f"{team.lname} • Season {get_config().sba_current_season}",
|
||||
description=f"{team.lname} • Season {get_config().sba_season}",
|
||||
color=embed_color
|
||||
)
|
||||
|
||||
|
||||
@ -282,7 +282,7 @@ class TradeCommands(commands.Cog):
|
||||
return
|
||||
|
||||
# Find the player
|
||||
players = await player_service.search_players(player_name, limit=10, season=get_config().sba_current_season)
|
||||
players = await player_service.search_players(player_name, limit=10, season=get_config().sba_season)
|
||||
if not players:
|
||||
await interaction.followup.send(
|
||||
f"❌ Player '{player_name}' not found.",
|
||||
@ -392,7 +392,7 @@ class TradeCommands(commands.Cog):
|
||||
return
|
||||
|
||||
# Find the player
|
||||
players = await player_service.search_players(player_name, limit=10, season=get_config().sba_current_season)
|
||||
players = await player_service.search_players(player_name, limit=10, season=get_config().sba_season)
|
||||
if not players:
|
||||
await interaction.followup.send(
|
||||
f"❌ Player '{player_name}' not found.",
|
||||
|
||||
@ -61,7 +61,7 @@ class VoiceChannelCommands(commands.Cog):
|
||||
Returns:
|
||||
Team object or None if not found
|
||||
"""
|
||||
season = season or get_config().sba_current_season
|
||||
season = season or get_config().sba_season
|
||||
teams = await team_service.get_teams_by_owner(user_id, season)
|
||||
return teams[0] if teams else None
|
||||
|
||||
@ -76,7 +76,7 @@ class VoiceChannelCommands(commands.Cog):
|
||||
Returns:
|
||||
Major League Team object or None if not found
|
||||
"""
|
||||
season = season or get_config().sba_current_season
|
||||
season = season or get_config().sba_season
|
||||
teams = await team_service.get_teams_by_owner(user_id, season)
|
||||
|
||||
# Filter to only Major League teams (3-character abbreviations)
|
||||
|
||||
@ -26,8 +26,8 @@ class BotConfig(BaseSettings):
|
||||
discord_embed_description_limit: int = 4096
|
||||
|
||||
# League settings
|
||||
sba_season: int = 12
|
||||
pd_season: int = 9
|
||||
sba_season: int = 13
|
||||
pd_season: int = 10
|
||||
fa_lock_week: int = 14
|
||||
sba_color: str = "a6ce39"
|
||||
weeks_per_season: int = 18
|
||||
@ -39,9 +39,6 @@ class BotConfig(BaseSettings):
|
||||
modern_stats_start_season: int = 8
|
||||
offseason_flag: bool = False # When True, relaxes roster limits and disables weekly freeze/thaw
|
||||
|
||||
# Current Season Constants
|
||||
sba_current_season: int = 12
|
||||
pd_current_season: int = 9
|
||||
|
||||
# API Constants
|
||||
api_version: str = "v3"
|
||||
|
||||
@ -169,7 +169,7 @@ class DraftService(BaseService[DraftData]):
|
||||
from config import get_config
|
||||
|
||||
config = get_config()
|
||||
season = config.sba_current_season
|
||||
season = config.sba_season
|
||||
total_picks = config.draft_total_picks
|
||||
|
||||
# Start with next pick
|
||||
|
||||
@ -113,7 +113,7 @@ class LeagueService(BaseService[Current]):
|
||||
List of standings data or None if not available
|
||||
"""
|
||||
try:
|
||||
season = season or get_config().sba_current_season
|
||||
season = season or get_config().sba_season
|
||||
client = await self.get_client()
|
||||
data = await client.get('standings', params=[('season', str(season))])
|
||||
|
||||
@ -146,7 +146,7 @@ class LeagueService(BaseService[Current]):
|
||||
List of division standings or None if not available
|
||||
"""
|
||||
try:
|
||||
season = season or get_config().sba_current_season
|
||||
season = season or get_config().sba_season
|
||||
client = await self.get_client()
|
||||
data = await client.get(f'standings/division/{division_id}', params=[('season', str(season))])
|
||||
|
||||
@ -174,7 +174,7 @@ class LeagueService(BaseService[Current]):
|
||||
List of league leaders or None if not available
|
||||
"""
|
||||
try:
|
||||
season = season or get_config().sba_current_season
|
||||
season = season or get_config().sba_season
|
||||
client = await self.get_client()
|
||||
|
||||
params = [
|
||||
|
||||
@ -192,7 +192,7 @@ class PlayerService(BaseService[Player]):
|
||||
"""
|
||||
try:
|
||||
if season is None:
|
||||
season = get_config().sba_current_season
|
||||
season = get_config().sba_season
|
||||
|
||||
# Use the existing name-based search that actually works
|
||||
players = await self.get_players_by_name(query, season)
|
||||
|
||||
@ -79,7 +79,7 @@ class TeamService(BaseService[Team]):
|
||||
Exception: If there's an error communicating with the API
|
||||
Allows caller to distinguish between "no teams" vs "error occurred"
|
||||
"""
|
||||
season = season or get_config().sba_current_season
|
||||
season = season or get_config().sba_season
|
||||
params = [
|
||||
('owner_id', str(owner_id)),
|
||||
('season', str(season))
|
||||
@ -139,7 +139,7 @@ class TeamService(BaseService[Team]):
|
||||
Team instance or None if not found
|
||||
"""
|
||||
try:
|
||||
season = season or get_config().sba_current_season
|
||||
season = season or get_config().sba_season
|
||||
params = [
|
||||
('team_abbrev', abbrev.upper()),
|
||||
('season', str(season))
|
||||
@ -336,7 +336,7 @@ class TeamService(BaseService[Team]):
|
||||
Returns:
|
||||
List of teams in current season
|
||||
"""
|
||||
return await self.get_teams_by_season(get_config().sba_current_season)
|
||||
return await self.get_teams_by_season(get_config().sba_season)
|
||||
|
||||
|
||||
# Global service instance
|
||||
|
||||
@ -66,7 +66,7 @@ class TradeBuilder:
|
||||
Extends the functionality of TransactionBuilder to support trades between teams.
|
||||
"""
|
||||
|
||||
def __init__(self, initiated_by: int, initiating_team: Team, season: int = get_config().sba_current_season):
|
||||
def __init__(self, initiated_by: int, initiating_team: Team, season: int = get_config().sba_season):
|
||||
"""
|
||||
Initialize trade builder.
|
||||
|
||||
|
||||
@ -136,7 +136,7 @@ class RosterValidationResult:
|
||||
class TransactionBuilder:
|
||||
"""Interactive transaction builder for complex multi-move transactions."""
|
||||
|
||||
def __init__(self, team: Team, user_id: int, season: int = get_config().sba_current_season):
|
||||
def __init__(self, team: Team, user_id: int, season: int = get_config().sba_season):
|
||||
"""
|
||||
Initialize transaction builder.
|
||||
|
||||
|
||||
@ -115,7 +115,7 @@ class DraftMonitorTask:
|
||||
|
||||
# Get current pick
|
||||
current_pick = await draft_pick_service.get_pick(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
draft_data.currentpick
|
||||
)
|
||||
|
||||
@ -169,7 +169,7 @@ class DraftMonitorTask:
|
||||
|
||||
# Get team's draft list
|
||||
draft_list = await draft_list_service.get_team_list(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
current_pick.owner.id
|
||||
)
|
||||
|
||||
@ -315,7 +315,7 @@ class DraftMonitorTask:
|
||||
|
||||
# Get current pick for mention
|
||||
current_pick = await draft_pick_service.get_pick(
|
||||
config.sba_current_season,
|
||||
config.sba_season,
|
||||
draft_data.currentpick
|
||||
)
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ async def test_player_search():
|
||||
try:
|
||||
# Test 1: Search for a common name (should find multiple)
|
||||
logger.info("Testing search for common player name")
|
||||
players = await player_service.get_players_by_name("Smith", get_config().sba_current_season)
|
||||
players = await player_service.get_players_by_name("Smith", get_config().sba_season)
|
||||
logger.info("Common name search completed",
|
||||
search_term="Smith",
|
||||
results_found=len(players))
|
||||
@ -82,7 +82,7 @@ async def test_player_search():
|
||||
|
||||
# Test 2: Search for specific player (exact match)
|
||||
logger.info("Testing search for specific player")
|
||||
players = await player_service.get_players_by_name("Mike Trout", get_config().sba_current_season)
|
||||
players = await player_service.get_players_by_name("Mike Trout", get_config().sba_season)
|
||||
logger.info("Specific player search completed",
|
||||
search_term="Mike Trout",
|
||||
results_found=len(players))
|
||||
@ -144,7 +144,7 @@ async def test_player_service_methods():
|
||||
# Test get_all with limit (need to include season)
|
||||
logger.info("Testing get_all with limit")
|
||||
players, total_count = await player_service.get_all(params=[
|
||||
('season', str(get_config().sba_current_season)),
|
||||
('season', str(get_config().sba_season)),
|
||||
('limit', '10')
|
||||
])
|
||||
|
||||
@ -153,7 +153,7 @@ async def test_player_service_methods():
|
||||
retrieved_count=len(players),
|
||||
total_count=total_count,
|
||||
limit=10,
|
||||
season=get_config().sba_current_season)
|
||||
season=get_config().sba_season)
|
||||
|
||||
if players:
|
||||
print(" Sample players:")
|
||||
@ -164,7 +164,7 @@ async def test_player_service_methods():
|
||||
if players:
|
||||
test_position = players[0].primary_position
|
||||
logger.info("Testing position search", position=test_position)
|
||||
position_players = await player_service.get_players_by_position(test_position, get_config().sba_current_season)
|
||||
position_players = await player_service.get_players_by_position(test_position, get_config().sba_season)
|
||||
|
||||
print(f" ✅ Found {len(position_players)} players at position {test_position}")
|
||||
logger.info("Position search completed",
|
||||
|
||||
@ -259,8 +259,8 @@ class TestTeamService:
|
||||
mock_data = {
|
||||
'count': 2,
|
||||
'teams': [
|
||||
self.create_team_data(1, 'TEA', season=get_config().sba_current_season),
|
||||
self.create_team_data(2, 'TEB', season=get_config().sba_current_season)
|
||||
self.create_team_data(1, 'TEA', season=get_config().sba_season),
|
||||
self.create_team_data(2, 'TEB', season=get_config().sba_season)
|
||||
]
|
||||
}
|
||||
mock_client.get.return_value = mock_data
|
||||
@ -268,8 +268,8 @@ class TestTeamService:
|
||||
result = await team_service_instance.get_current_season_teams()
|
||||
|
||||
assert len(result) == 2
|
||||
assert all(team.season == get_config().sba_current_season for team in result)
|
||||
mock_client.get.assert_called_once_with('teams', params=[('season', str(get_config().sba_current_season))])
|
||||
assert all(team.season == get_config().sba_season for team in result)
|
||||
mock_client.get.assert_called_once_with('teams', params=[('season', str(get_config().sba_season))])
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_error_handling(self, team_service_instance, mock_client):
|
||||
|
||||
@ -37,7 +37,7 @@ async def player_autocomplete(
|
||||
user_team = await get_user_major_league_team(interaction.user.id)
|
||||
|
||||
# Search for players using the search endpoint
|
||||
players = await player_service.search_players(current, limit=50, season=get_config().sba_current_season)
|
||||
players = await player_service.search_players(current, limit=50, season=get_config().sba_season)
|
||||
|
||||
# Separate players by team (user's team vs others)
|
||||
user_team_players = []
|
||||
@ -105,7 +105,7 @@ async def team_autocomplete(
|
||||
|
||||
try:
|
||||
# Get all teams for current season
|
||||
teams = await team_service.get_teams_by_season(get_config().sba_current_season)
|
||||
teams = await team_service.get_teams_by_season(get_config().sba_season)
|
||||
|
||||
# Filter teams by current input and limit to 25
|
||||
matching_teams = [
|
||||
@ -146,7 +146,7 @@ async def major_league_team_autocomplete(
|
||||
|
||||
try:
|
||||
# Get all teams for current season
|
||||
all_teams = await team_service.get_teams_by_season(get_config().sba_current_season)
|
||||
all_teams = await team_service.get_teams_by_season(get_config().sba_season)
|
||||
|
||||
# Filter to only Major League teams using the model's helper method
|
||||
from models.team import RosterType
|
||||
|
||||
@ -55,7 +55,7 @@ async def get_user_team(user_id: int) -> Optional[dict]:
|
||||
config = get_config()
|
||||
team = await team_service.get_team_by_owner(
|
||||
owner_id=user_id,
|
||||
season=config.sba_current_season
|
||||
season=config.sba_season
|
||||
)
|
||||
|
||||
if team:
|
||||
|
||||
@ -13,7 +13,7 @@ from config import get_config
|
||||
|
||||
async def get_user_major_league_team(
|
||||
user_id: int,
|
||||
season: int = get_config().sba_current_season
|
||||
season: int = get_config().sba_season
|
||||
) -> Optional[Team]:
|
||||
"""
|
||||
Get the major league team owned by a Discord user.
|
||||
@ -47,7 +47,7 @@ async def get_user_major_league_team(
|
||||
|
||||
async def validate_user_has_team(
|
||||
interaction: discord.Interaction,
|
||||
season: int = get_config().sba_current_season
|
||||
season: int = get_config().sba_season
|
||||
) -> Optional[Team]:
|
||||
"""
|
||||
Validate that a user has a major league team and send error message if not.
|
||||
@ -76,7 +76,7 @@ async def validate_user_has_team(
|
||||
async def get_team_by_abbrev_with_validation(
|
||||
team_abbrev: str,
|
||||
interaction: discord.Interaction,
|
||||
season: int = get_config().sba_current_season
|
||||
season: int = get_config().sba_season
|
||||
) -> Optional[Team]:
|
||||
"""
|
||||
Get a team by abbreviation with standard error messaging.
|
||||
|
||||
@ -155,7 +155,7 @@ class SBAEmbedTemplate(EmbedTemplate):
|
||||
|
||||
embed.add_field(
|
||||
name="Season",
|
||||
value=str(season or get_config().sba_current_season),
|
||||
value=str(season or get_config().sba_season),
|
||||
inline=True
|
||||
)
|
||||
|
||||
@ -192,7 +192,7 @@ class SBAEmbedTemplate(EmbedTemplate):
|
||||
|
||||
embed = EmbedTemplate.create_base_embed(
|
||||
title=f"{team_abbrev} - {team_name}",
|
||||
description=f"Season {season or get_config().sba_current_season} Team Information",
|
||||
description=f"Season {season or get_config().sba_season} Team Information",
|
||||
color=color
|
||||
)
|
||||
|
||||
@ -201,7 +201,7 @@ class SBAEmbedTemplate(EmbedTemplate):
|
||||
embed.add_field(name="Short Name", value=short_name, inline=True)
|
||||
|
||||
embed.add_field(name="Abbreviation", value=team_abbrev, inline=True)
|
||||
embed.add_field(name="Season", value=str(season or get_config().sba_current_season), inline=True)
|
||||
embed.add_field(name="Season", value=str(season or get_config().sba_season), inline=True)
|
||||
|
||||
if stadium:
|
||||
embed.add_field(name="Stadium", value=stadium, inline=True)
|
||||
@ -276,7 +276,7 @@ class SBAEmbedTemplate(EmbedTemplate):
|
||||
|
||||
embed = EmbedTemplate.create_base_embed(
|
||||
title=f"{team_abbrev} - {roster_type}",
|
||||
description=f"{team_name} • Season {season or get_config().sba_current_season}",
|
||||
description=f"{team_name} • Season {season or get_config().sba_season}",
|
||||
color=color
|
||||
)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user