Update helpers.py

Season 5 updates
This commit is contained in:
Cal Corum 2023-04-25 01:43:31 -05:00
parent 30cc6d2af7
commit 6865669008

View File

@ -18,7 +18,7 @@ from typing import Optional, Literal
SBA_SEASON = 7
PD_SEASON = 4
PD_SEASON = 5
SBA_COLOR = 'a6ce39'
PD_PLAYERS = 'Paper Dynasty Players'
SBA_PLAYERS_ROLE_NAME = f'Season {SBA_SEASON} Players'
@ -1975,6 +1975,7 @@ def create_team_sheet(team, email: str, current, bot):
async def refresh_sheet(team, bot, sheets=None) -> None:
return
if not sheets:
sheets = get_sheets(bot)
@ -2192,7 +2193,7 @@ def team_summary_embed(team, ctx, include_roster: bool = True):
embed.add_field(name='Unopened Packs', value=pack_string)
embed.add_field(name='Team Rating', value=f'{team["ranking"]}')
r_query = db_get(f'results/team/{team["id"]}')
r_query = db_get(f'results/team/{team["id"]}?season={PD_SEASON}')
if r_query:
embed.add_field(
name='Record',
@ -2200,32 +2201,32 @@ def team_summary_embed(team, ctx, include_roster: bool = True):
f'Unlimited: {r_query["casual_wins"]}-{r_query["casual_losses"]}'
)
try:
r_query = db_get('rosters', params=[('team_id', team['id'])])
if r_query['count']:
embed.add_field(name=f'Rosters', value=f'** **', inline=False)
for roster in r_query['rosters']:
roster_string = ''
for i in range(1, 27):
card = roster[f'card_{i}']
roster_string += f'{card["player"]["description"]} ({card["player"]["pos_1"]})\n'
embed.add_field(
name=f'{roster["name"]} Roster',
value=roster_string if len(roster_string) else "Unknown"
)
else:
embed.add_field(
name='Rosters',
value='You can set up to three rosters for quick switching from your team sheet.',
inline=False
)
except Exception as e:
logging.error(f'Could not pull rosters for {team["abbrev"]}')
embed.add_field(
name='Rosters',
value='Unable to pull current rosters. `/pullroster` to sync.',
inline=False
)
# try:
# r_query = db_get('rosters', params=[('team_id', team['id'])])
# if r_query['count']:
# embed.add_field(name=f'Rosters', value=f'** **', inline=False)
# for roster in r_query['rosters']:
# roster_string = ''
# for i in range(1, 27):
# card = roster[f'card_{i}']
# roster_string += f'{card["player"]["description"]} ({card["player"]["pos_1"]})\n'
# embed.add_field(
# name=f'{roster["name"]} Roster',
# value=roster_string if len(roster_string) else "Unknown"
# )
# else:
# embed.add_field(
# name='Rosters',
# value='You can set up to three rosters for quick switching from your team sheet.',
# inline=False
# )
# except Exception as e:
# logging.error(f'Could not pull rosters for {team["abbrev"]}')
# embed.add_field(
# name='Rosters',
# value='Unable to pull current rosters. `/pullroster` to sync.',
# inline=False
# )
if include_roster:
embed.add_field(name='Team Sheet', value=get_roster_sheet(team, allow_embed=True), inline=False)