Live scorecard fix

Gauntlet entry string fix
This commit is contained in:
Cal Corum 2025-03-31 13:54:39 -05:00
parent 9218bd6047
commit cb2637086e
2 changed files with 15 additions and 11 deletions

View File

@ -72,17 +72,21 @@ class Gameplay(commands.Cog):
with Session(engine) as session:
for key in self.game_states:
if not self.game_states[key]['ack']:
if not self.game_states[key]['play'].game.active:
logger.info(f'Game {self.game_states[key]["play"].game.id} is complete, removing from game_states')
this_game = session.get(Game, key)
if this_game is None:
log_exception(GameNotFoundException, f'Could not pull game #{key} for live scorecard')
if not this_game.active:
logger.info(f'Game {this_game.id} is complete, removing from game_states')
del self.game_states[key]
else:
try:
logger.info(f'Appending scorebug for Game {self.game_states[key]["play"].game.id}')
this_channel = discord.utils.get(guild.text_channels, id=self.game_states[key]["play"].game.channel_id)
logger.info(f'Appending scorebug for Game {this_game.id}')
this_channel = discord.utils.get(guild.text_channels, id=this_game.channel_id)
logger.info(f'this_channel: {this_channel}')
this_embed = await get_scorebug_embed(session, self.game_states[key]["play"].game, full_length=False, live_scorecard=True)
this_embed = await get_scorebug_embed(session, this_game, full_length=False, live_scorecard=True)
this_embed.set_image(url=None)
this_embed.insert_field_at(
index=0,
@ -94,7 +98,7 @@ class Gameplay(commands.Cog):
self.game_states[key]['ack'] = True
except Exception as e:
logger.error(f'Unable to add to game_states: {e}')
logger.error(f'Game: {self.game_states[key]["play"].game.id}')
logger.error(f'Game: {this_game.id}')
if len(all_embeds) == 0:
logger.info(f'No active game embeds, returning')
@ -108,10 +112,10 @@ class Gameplay(commands.Cog):
await score_channel.send(content=None, embeds=all_embeds)
except Exception as e:
logger.error(f'Failed running live scorecard: {e}')
try:
await send_to_channel(self.bot, 'commissioners-office', f'PD Live Scorecard just failed: {e}')
except Exception as e:
logger.error(f'Couldn\'t even send the error to the private channel :/')
# try:
# await send_to_channel(self.bot, 'commissioners-office', f'PD Live Scorecard just failed: {e}')
# except Exception as e:
# logger.error(f'Couldn\'t even send the error to the private channel :/')
@live_scorecard.before_loop
async def before_live_scoreboard(self):

View File

@ -1022,7 +1022,7 @@ class Players(commands.Cog):
await helpers.send_to_channel(
bot=self.bot,
channel_name='pd-news-ticker',
content=f'The {main_team["lname"]} have entered the {this_event["name"]} Gauntlet!',
content=f'The {main_team.lname} have entered the {this_event["name"]} Gauntlet!',
embed=draft_embed
)