Added full_length param to /scorebug
This commit is contained in:
parent
fb94827820
commit
c21c966caa
@ -131,24 +131,31 @@ class Players(commands.Cog):
|
||||
|
||||
return embed
|
||||
|
||||
async def game_scorebug(self, sheets_data, include_images: bool = True):
|
||||
async def game_scorebug(self, sheets_data, include_images: bool = True, full_length: bool = True):
|
||||
away_team = await db_get('teams', object_id=sheets_data.get_value('B5'))
|
||||
home_team = await db_get('teams', object_id=sheets_data.get_value('B6'))
|
||||
logging.info(f'getting gamestate')
|
||||
game_state = sheets_data.get_values('B2', 'G8', include_tailing_empty_rows=True)
|
||||
logging.info(f'getting gamestate / full_length: {full_length}')
|
||||
all_data = sheets_data.get_values('B2', 'S20', include_tailing_empty_rows=True)
|
||||
# game_state = sheets_data.get_values('B2', 'G8', include_tailing_empty_rows=True)
|
||||
game_state = [
|
||||
all_data[0][:6], all_data[1][:6], all_data[2][:6], all_data[3][:6],
|
||||
all_data[4][:6], all_data[5][:6], all_data[6][:6]
|
||||
]
|
||||
logging.info(f'gamestate: {game_state}')
|
||||
header = game_state[0][0]
|
||||
is_final = header[-5:] == 'FINAL'
|
||||
inning_desc = {header.split(" - ")[1]}
|
||||
# inning_desc = {header.split(" - ")[1]}
|
||||
away_score = game_state[3][2]
|
||||
home_score = game_state[4][2]
|
||||
which_half = game_state[3][4]
|
||||
logging.info(f'getting runners')
|
||||
runners = sheets_data.get_values('K11', 'L14', include_tailing_empty_rows=True)
|
||||
|
||||
# runners = sheets_data.get_values('K11', 'L14', include_tailing_empty_rows=True)
|
||||
runners = [
|
||||
all_data[9][9:11], all_data[10][9:11], all_data[11][9:11], all_data[12][9:11]
|
||||
]
|
||||
logging.info(f'runners: {runners}')
|
||||
logging.info(f'getting matchups')
|
||||
matchups = sheets_data.get_values('K3', 'O6', include_tailing_empty_rows=True)
|
||||
logging.info(f'matchups: {matchups}')
|
||||
|
||||
this_embed = get_team_embed(
|
||||
# title=f'[{away_team["sname"]}]({get_team_url(away_team)}) @ '
|
||||
@ -187,6 +194,17 @@ class Players(commands.Cog):
|
||||
inline=False
|
||||
)
|
||||
|
||||
logging.info(f'Checking if not full_length')
|
||||
if not full_length:
|
||||
logging.info(f'not full_length, returning now')
|
||||
return this_embed
|
||||
|
||||
# matchups = sheets_data.get_values('K3', 'O6', include_tailing_empty_rows=True)
|
||||
matchups = [
|
||||
all_data[1][9:14], all_data[2][9:14], all_data[3][9:14], all_data[4][9:14],
|
||||
]
|
||||
logging.info(f'matchups: {matchups}')
|
||||
|
||||
p_name = matchups[0][0]
|
||||
this_embed.add_field(
|
||||
name='Pitcher',
|
||||
@ -2219,8 +2237,9 @@ class Players(commands.Cog):
|
||||
f'this channel to get the scorebug.')
|
||||
|
||||
@app_commands.command(name='scorebug', description='Pull the scorebug for the game in this channel')
|
||||
@app_commands.describe(full_length='Include the full game summary, defaults to True')
|
||||
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME, PD_PLAYERS_ROLE_NAME)
|
||||
async def scorebug_slash(self, interaction: discord.Interaction):
|
||||
async def scorebug_slash(self, interaction: discord.Interaction, full_length: bool = True):
|
||||
if not self.scorecards:
|
||||
await interaction.response.send_message(
|
||||
'Uhh...I don\'t see any games in this channel. You in the right place?'
|
||||
@ -2236,8 +2255,9 @@ class Players(commands.Cog):
|
||||
|
||||
await interaction.response.send_message(f'I am checking sheets now...', ephemeral=True)
|
||||
|
||||
logging.info(f'scorebug_slash: full_length: {full_length}')
|
||||
try:
|
||||
game_embed = await self.game_scorebug(this_scorecard)
|
||||
game_embed = await self.game_scorebug(this_scorecard, full_length=full_length)
|
||||
await interaction.edit_original_response(content=None, embed=game_embed)
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user