From cb2637086e1926928c4d3af0a50c5f714eddea29 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Mon, 31 Mar 2025 13:54:39 -0500 Subject: [PATCH] Live scorecard fix Gauntlet entry string fix --- cogs/gameplay.py | 24 ++++++++++++++---------- cogs/players.py | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/cogs/gameplay.py b/cogs/gameplay.py index 318b2eb..ce96ed6 100644 --- a/cogs/gameplay.py +++ b/cogs/gameplay.py @@ -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): diff --git a/cogs/players.py b/cogs/players.py index 5620e28..02cca7d 100644 --- a/cogs/players.py +++ b/cogs/players.py @@ -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 )