Add sba_logo_url to the config and update /standings formatting
This commit is contained in:
parent
f6a7967e49
commit
a8fbf55c9e
@ -9,6 +9,7 @@ import discord
|
|||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
from config import get_config
|
from config import get_config
|
||||||
|
from models.team import Team
|
||||||
from services.standings_service import standings_service
|
from services.standings_service import standings_service
|
||||||
from utils.logging import get_contextual_logger
|
from utils.logging import get_contextual_logger
|
||||||
from utils.decorators import logged_command
|
from utils.decorators import logged_command
|
||||||
@ -101,13 +102,15 @@ class StandingsCommands(commands.Cog):
|
|||||||
embed = await self._create_division_embed(div_name, teams, season)
|
embed = await self._create_division_embed(div_name, teams, season)
|
||||||
embeds.append(embed)
|
embeds.append(embed)
|
||||||
|
|
||||||
# Send first embed, then follow up with others
|
await interaction.followup.send(embeds=embeds)
|
||||||
if embeds:
|
|
||||||
await interaction.followup.send(embed=embeds[0])
|
|
||||||
|
|
||||||
# Send additional embeds as follow-ups
|
# # Send first embed, then follow up with others
|
||||||
for embed in embeds[1:]:
|
# if embeds:
|
||||||
await interaction.followup.send(embed=embed)
|
# await interaction.followup.send(embed=embeds[0])
|
||||||
|
|
||||||
|
# # Send additional embeds as follow-ups
|
||||||
|
# for embed in embeds[1:]:
|
||||||
|
# await interaction.followup.send(embed=embed)
|
||||||
|
|
||||||
async def _show_division_standings(self, interaction: discord.Interaction, season: int, division: str):
|
async def _show_division_standings(self, interaction: discord.Interaction, season: int, division: str):
|
||||||
"""Show standings for a specific division."""
|
"""Show standings for a specific division."""
|
||||||
@ -147,28 +150,37 @@ class StandingsCommands(commands.Cog):
|
|||||||
async def _create_division_embed(self, division_name: str, teams, season: int) -> discord.Embed:
|
async def _create_division_embed(self, division_name: str, teams, season: int) -> discord.Embed:
|
||||||
"""Create an embed for a division's standings."""
|
"""Create an embed for a division's standings."""
|
||||||
embed = EmbedTemplate.create_base_embed(
|
embed = EmbedTemplate.create_base_embed(
|
||||||
title=f"🏆 {division_name} Division - Season {season}",
|
title=f"{division_name} Division",
|
||||||
|
description=f'Season {season}',
|
||||||
color=EmbedColors.PRIMARY
|
color=EmbedColors.PRIMARY
|
||||||
)
|
)
|
||||||
|
lead_team = None
|
||||||
|
|
||||||
# Create standings table
|
# Create standings table
|
||||||
standings_lines = []
|
standing_text = f'```\n# Team W-L Win% RD GB St'
|
||||||
for i, team in enumerate(teams, 1):
|
for i, team in enumerate(teams, 1):
|
||||||
|
if lead_team is None:
|
||||||
|
lead_team = team.team
|
||||||
|
if lead_team.color is not None:
|
||||||
|
embed.color = int(lead_team.color, 16)
|
||||||
|
embed.description = f'Leader: {lead_team.lname}'
|
||||||
|
|
||||||
# Format team line
|
# Format team line
|
||||||
team_line = (
|
standing_text += f'\n{i}.{team.team.abbrev: >4} {team.wins: >2}-{team.losses: <2} {team.winning_percentage:.3f} {team.run_diff: >4}'
|
||||||
f"{i}. **{team.team.abbrev}** {team.wins}-{team.losses} "
|
|
||||||
f"({team.winning_percentage:.3f})"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Add games behind if not first place
|
# Add games behind if not first place
|
||||||
if team.div_gb is not None and team.div_gb > 0:
|
if team.div_gb is not None and team.div_gb > 0:
|
||||||
team_line += f" *{team.div_gb:.1f} GB*"
|
standing_text += f' {team.div_gb:4.1f}'
|
||||||
|
else:
|
||||||
|
standing_text += f' '
|
||||||
|
|
||||||
standings_lines.append(team_line)
|
standing_text += f' {team.streak_wl.upper()}{team.streak_num}'
|
||||||
|
|
||||||
|
standing_text += '\n```'
|
||||||
|
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="Standings",
|
name="Standings",
|
||||||
value="\n".join(standings_lines),
|
value=standing_text,
|
||||||
inline=False
|
inline=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -60,6 +60,7 @@ class BotConfig(BaseSettings):
|
|||||||
|
|
||||||
# Base URLs
|
# Base URLs
|
||||||
sba_base_url: str = "https://sba.manticorum.com"
|
sba_base_url: str = "https://sba.manticorum.com"
|
||||||
|
sba_logo_url: str = f'{sba_base_url}/images/sba-logo.png'
|
||||||
|
|
||||||
# Application settings
|
# Application settings
|
||||||
log_level: str = "INFO"
|
log_level: str = "INFO"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user