diff --git a/cogs/dice.py b/cogs/dice.py index 22e87a8..242b05c 100644 --- a/cogs/dice.py +++ b/cogs/dice.py @@ -219,152 +219,152 @@ class Dice(commands.Cog): # } # self.rolls.append(this_roll) - @app_commands.command(name='injury', description='Make an injury check; rating = left of "p", games = right') - @app_commands.guilds(discord.Object(id=os.environ.get('GUILD_ID'))) - @app_commands.choices(games=[ - Choice(name='86', value=86), - Choice(name='80', value=80), - Choice(name='70', value=70), - Choice(name='60', value=60), - Choice(name='50', value=50), - Choice(name='40', value=40), - Choice(name='30', value=30), - Choice(name='20', value=20), - ], rating=[ - Choice(name='1', value=1), - Choice(name='2', value=2), - Choice(name='3', value=3), - Choice(name='4', value=4), - Choice(name='5', value=5), - Choice(name='6', value=6), - ]) - async def injury_roll_slash(self, interaction: discord.Interaction, rating: Choice[int], games: Choice[int]): - team = None - await interaction.response.defer() - - d_six_one = random.randint(1, 6) - d_six_two = random.randint(1, 6) - d_six_three = random.randint(1, 6) - injury_roll = d_six_one + d_six_two + d_six_three - - inj_data = { - 'one': { - 'p86': ['OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'REM', 'REM', 1, 1, 2, 2, 3, 3, 4, 5], - 'p80': [2, 2, 'OK', 'REM', 1, 2, 3, 3, 4, 4, 5, 5, 6, 8, 12, 16], - 'p70': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 5, 6, 6, 8, 12, 16, 20, 20], - 'p60': ['OK', 'REM', 1, 2, 3, 4, 5, 6, 6, 8, 12, 12, 16, 20, 20, 'OK'], - 'p50': ['OK', 1, 2, 3, 4, 5, 6, 8, 8, 12, 12, 16, 20, 30, 'REM', 'OK'], - 'p40': ['OK', 5, 1, 3, 5, 6, 8, 12, 12, 16, 20, 30, 4, 2, 'REM', 'OK'], - 'p30': ['OK', 1, 2, 5, 6, 8, 12, 16, 20, 30, 12, 8, 4, 3, 'REM', 'OK'], - 'p20': ['OK', 1, 2, 5, 6, 12, 12, 30, 20, 16, 16, 8, 4, 3, 'REM', 'OK'] - }, - 'two': { - 'p86': [4, 3, 2, 2, 1, 1, 'REM', 'OK', 'REM', 'OK', 2, 1, 2, 2, 3, 5], - 'p80': [12, 6, 4, 2, 2, 'OK', 1, 'OK', 'REM', 1, 'REM', 2, 3, 5, 8, 16], - 'p70': [1, 3, 4, 6, 2, 2, 'OK', 1, 3, 'REM', 4, 5, 8, 12, 16, 3], - 'p60': [5, 'OK', 'OK', 'REM', 1, 2, 5, 3, 4, 6, 4, 8, 12, 16, 16, 'OK'], - 'p50': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 6, 5, 8, 12, 16, 20, 20, 'OK'], - 'p40': ['OK', 'REM', 1, 2, 3, 4, 5, 6, 8, 6, 12, 16, 20, 30, 'REM', 'OK'], - 'p30': ['OK', 1, 2, 4, 5, 6, 8, 6, 12, 16, 8, 20, 30, 3, 5, 'REM'], - 'p20': ['OK', 1, 4, 5, 6, 6, 8, 8, 16, 12, 20, 30, 12, 3, 2, 'REM'] - }, - 'three': { - 'p86': [], - 'p80': ['OK', 'OK', 'REM', 1, 3, 'OK', 'REM', 1, 2, 1, 2, 3, 4, 5, 6, 'REM'], - 'p70': ['OK', 6, 'OK', 'REM', 1, 2, 2, 3, 4, 5, 1, 3, 6, 8, 12, 'REM'], - 'p60': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 6, 4, 5, 8, 12, 12, 16, 'REM'], - 'p50': ['OK', 1, 1, 2, 3, 4, 5, 6, 8, 6, 8, 12, 12, 16, 5, 'REM'], - 'p40': ['OK', 1, 2, 3, 4, 6, 5, 8, 6, 8, 12, 12, 16, 20, 1, 'REM'], - 'p30': ['OK', 2, 3, 4, 5, 8, 6, 8, 12, 12, 16, 6, 20, 30, 1, 'REM'], - 'p20': ['OK', 1, 2, 4, 5, 12, 12, 8, 6, 16, 8, 20, 30, 3, 5, 'REM'] - }, - 'four': { - 'p86': [], - 'p80': [], - 'p70': ['OK', 'OK', 'REM', 3, 3, 'OK', 'REM', 1, 2, 1, 4, 5, 6, 8, 12, 'REM'], - 'p60': ['OK', 8, 4, 'OK', 'REM', 1, 2, 4, 5, 3, 6, 3, 8, 12, 16, 'REM'], - 'p50': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 6, 4, 5, 8, 12, 12, 16, 'REM'], - 'p40': ['OK', 1, 1, 2, 3, 4, 5, 6, 8, 6, 8, 12, 12, 16, 5, 'REM'], - 'p30': ['OK', 'REM', 2, 3, 4, 5, 6, 6, 8, 8, 16, 12, 12, 1, 20, 'REM'], - 'p20': ['OK', 1, 2, 3, 4, 6, 5, 8, 6, 8, 16, 12, 12, 20, 1, 'REM'] - }, - 'five': { - 'p86': [], - 'p80': [], - 'p70': [], - 'p60': ['OK', 'OK', 'REM', 1, 1, 'OK', 'REM', 3, 2, 4, 5, 6, 8, 6, 12, 16], - 'p50': ['OK', 8, 8, 'OK', 1, 3, 2, 4, 5, 6, 'REM', 3, 12, 8, 16, 1], - 'p40': ['OK', 'OK', 'REM', 5, 1, 2, 6, 4, 8, 3, 5, 12, 6, 8, 16, 'REM'], - 'p30': ['OK', 'REM', 2, 3, 5, 4, 6, 5, 8, 6, 12, 8, 3, 1, 16, 'REM'], - 'p20': ['OK', 'REM', 2, 3, 5, 4, 6, 5, 8, 6, 12, 8, 12, 1, 16, 'REM'] - }, - 'six': { - 'p86': [], - 'p80': [], - 'p70': [], - 'p60': [], - 'p50': ['OK', 8, 3, 'OK', 1, 3, 2, 4, 5, 6, 'REM', 8, 12, 3, 16, 1], - 'p40': ['OK', 'OK', 'REM', 5, 1, 3, 8, 4, 6, 2, 5, 12, 3, 4, 16, 'REM'], - 'p30': ['OK', 'REM', 4, 5, 2, 3, 6, 4, 8, 5, 12, 6, 3, 1, 16, 'REM'], - 'p20': ['OK', 'REM', 2, 3, 5, 4, 6, 5, 8, 6, 12, 8, 12, 1, 16, 'REM'] - } - } - p_ratings = ['one', 'two', 'three', 'four', 'five', 'six'] - - injury_string = f'```md\n# {injury_roll}\n' \ - f'Details:[3d6 ({d_six_one} {d_six_two} {d_six_three})]\n```\n' - - logging.info(f'injury rating: {rating.value}p{games.value}') - - injury_list = inj_data[p_ratings[rating.value - 1]][f'p{games.value}'] - injury_result = injury_list[injury_roll - 3] - logging.info( - f'injury rating: {rating.value}p{games.value} / array: {injury_list}[{injury_roll - 2}] / result: {injury_result}') - - if isinstance(injury_result, int): - try: - await interaction.edit_original_response( - content=random_gif(random_from_list(['salute', 'press f', 'pay respects'])) - ) - except Exception as e: - logging.info(f'failed to post funny gif') - injury_string += f'With a roll of {injury_roll}, the injury length is **{injury_result} ' \ - f'game{"s" if injury_result > 1 else ""}**.' - elif injury_result == 'REM': - try: - await interaction.edit_original_response( - content=random_gif(random_from_list(['could be worse', 'not too bad'])) - ) - except Exception as e: - logging.info(f'failed to post funny gif') - injury_string += f'With a roll of {injury_roll}, the injury length is **REMAINDER OF GAME** for batters ' \ - f'or **FATIGUED** for pitchers' - else: - try: - await interaction.edit_original_response( - content=random_gif(random_from_list(['it is fine', 'nothing to see here', 'i wasn\'t worried'])) - ) - except Exception as e: - logging.info(f'failed to post funny gif') - injury_string += f'With a roll of {injury_roll}, the player is **OKAY** - no injury!' - - embed = await self.get_dice_embed( - interaction.channel.name, - f'Injury roll for {interaction.user.name}', - injury_string - ) - embed.set_footer(text='For pitchers, add their current rest to the injury') - - await interaction.channel.send(content=None, embed=embed) - - # this_roll = { - # 'season': self.current['season'], - # 'week': self.current['week'], - # 'team_id': team["id"] if team else None, - # 'roller': interaction.user.id, - # 'threedsix': d_six_one + d_six_two + d_six_three - # } - # self.rolls.append(this_roll) + # @app_commands.command(name='injury', description='Make an injury check; rating = left of "p", games = right') + # @app_commands.guilds(discord.Object(id=os.environ.get('GUILD_ID'))) + # @app_commands.choices(games=[ + # Choice(name='86', value=86), + # Choice(name='80', value=80), + # Choice(name='70', value=70), + # Choice(name='60', value=60), + # Choice(name='50', value=50), + # Choice(name='40', value=40), + # Choice(name='30', value=30), + # Choice(name='20', value=20), + # ], rating=[ + # Choice(name='1', value=1), + # Choice(name='2', value=2), + # Choice(name='3', value=3), + # Choice(name='4', value=4), + # Choice(name='5', value=5), + # Choice(name='6', value=6), + # ]) + # async def injury_roll_slash(self, interaction: discord.Interaction, rating: Choice[int], games: Choice[int]): + # team = None + # await interaction.response.defer() + # + # d_six_one = random.randint(1, 6) + # d_six_two = random.randint(1, 6) + # d_six_three = random.randint(1, 6) + # injury_roll = d_six_one + d_six_two + d_six_three + # + # inj_data = { + # 'one': { + # 'p86': ['OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'REM', 'REM', 1, 1, 2, 2, 3, 3, 4, 5], + # 'p80': [2, 2, 'OK', 'REM', 1, 2, 3, 3, 4, 4, 5, 5, 6, 8, 12, 16], + # 'p70': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 5, 6, 6, 8, 12, 16, 20, 20], + # 'p60': ['OK', 'REM', 1, 2, 3, 4, 5, 6, 6, 8, 12, 12, 16, 20, 20, 'OK'], + # 'p50': ['OK', 1, 2, 3, 4, 5, 6, 8, 8, 12, 12, 16, 20, 30, 'REM', 'OK'], + # 'p40': ['OK', 5, 1, 3, 5, 6, 8, 12, 12, 16, 20, 30, 4, 2, 'REM', 'OK'], + # 'p30': ['OK', 1, 2, 5, 6, 8, 12, 16, 20, 30, 12, 8, 4, 3, 'REM', 'OK'], + # 'p20': ['OK', 1, 2, 5, 6, 12, 12, 30, 20, 16, 16, 8, 4, 3, 'REM', 'OK'] + # }, + # 'two': { + # 'p86': [4, 3, 2, 2, 1, 1, 'REM', 'OK', 'REM', 'OK', 2, 1, 2, 2, 3, 5], + # 'p80': [12, 6, 4, 2, 2, 'OK', 1, 'OK', 'REM', 1, 'REM', 2, 3, 5, 8, 16], + # 'p70': [1, 3, 4, 6, 2, 2, 'OK', 1, 3, 'REM', 4, 5, 8, 12, 16, 3], + # 'p60': [5, 'OK', 'OK', 'REM', 1, 2, 5, 3, 4, 6, 4, 8, 12, 16, 16, 'OK'], + # 'p50': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 6, 5, 8, 12, 16, 20, 20, 'OK'], + # 'p40': ['OK', 'REM', 1, 2, 3, 4, 5, 6, 8, 6, 12, 16, 20, 30, 'REM', 'OK'], + # 'p30': ['OK', 1, 2, 4, 5, 6, 8, 6, 12, 16, 8, 20, 30, 3, 5, 'REM'], + # 'p20': ['OK', 1, 4, 5, 6, 6, 8, 8, 16, 12, 20, 30, 12, 3, 2, 'REM'] + # }, + # 'three': { + # 'p86': [], + # 'p80': ['OK', 'OK', 'REM', 1, 3, 'OK', 'REM', 1, 2, 1, 2, 3, 4, 5, 6, 'REM'], + # 'p70': ['OK', 6, 'OK', 'REM', 1, 2, 2, 3, 4, 5, 1, 3, 6, 8, 12, 'REM'], + # 'p60': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 6, 4, 5, 8, 12, 12, 16, 'REM'], + # 'p50': ['OK', 1, 1, 2, 3, 4, 5, 6, 8, 6, 8, 12, 12, 16, 5, 'REM'], + # 'p40': ['OK', 1, 2, 3, 4, 6, 5, 8, 6, 8, 12, 12, 16, 20, 1, 'REM'], + # 'p30': ['OK', 2, 3, 4, 5, 8, 6, 8, 12, 12, 16, 6, 20, 30, 1, 'REM'], + # 'p20': ['OK', 1, 2, 4, 5, 12, 12, 8, 6, 16, 8, 20, 30, 3, 5, 'REM'] + # }, + # 'four': { + # 'p86': [], + # 'p80': [], + # 'p70': ['OK', 'OK', 'REM', 3, 3, 'OK', 'REM', 1, 2, 1, 4, 5, 6, 8, 12, 'REM'], + # 'p60': ['OK', 8, 4, 'OK', 'REM', 1, 2, 4, 5, 3, 6, 3, 8, 12, 16, 'REM'], + # 'p50': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 6, 4, 5, 8, 12, 12, 16, 'REM'], + # 'p40': ['OK', 1, 1, 2, 3, 4, 5, 6, 8, 6, 8, 12, 12, 16, 5, 'REM'], + # 'p30': ['OK', 'REM', 2, 3, 4, 5, 6, 6, 8, 8, 16, 12, 12, 1, 20, 'REM'], + # 'p20': ['OK', 1, 2, 3, 4, 6, 5, 8, 6, 8, 16, 12, 12, 20, 1, 'REM'] + # }, + # 'five': { + # 'p86': [], + # 'p80': [], + # 'p70': [], + # 'p60': ['OK', 'OK', 'REM', 1, 1, 'OK', 'REM', 3, 2, 4, 5, 6, 8, 6, 12, 16], + # 'p50': ['OK', 8, 8, 'OK', 1, 3, 2, 4, 5, 6, 'REM', 3, 12, 8, 16, 1], + # 'p40': ['OK', 'OK', 'REM', 5, 1, 2, 6, 4, 8, 3, 5, 12, 6, 8, 16, 'REM'], + # 'p30': ['OK', 'REM', 2, 3, 5, 4, 6, 5, 8, 6, 12, 8, 3, 1, 16, 'REM'], + # 'p20': ['OK', 'REM', 2, 3, 5, 4, 6, 5, 8, 6, 12, 8, 12, 1, 16, 'REM'] + # }, + # 'six': { + # 'p86': [], + # 'p80': [], + # 'p70': [], + # 'p60': [], + # 'p50': ['OK', 8, 3, 'OK', 1, 3, 2, 4, 5, 6, 'REM', 8, 12, 3, 16, 1], + # 'p40': ['OK', 'OK', 'REM', 5, 1, 3, 8, 4, 6, 2, 5, 12, 3, 4, 16, 'REM'], + # 'p30': ['OK', 'REM', 4, 5, 2, 3, 6, 4, 8, 5, 12, 6, 3, 1, 16, 'REM'], + # 'p20': ['OK', 'REM', 2, 3, 5, 4, 6, 5, 8, 6, 12, 8, 12, 1, 16, 'REM'] + # } + # } + # p_ratings = ['one', 'two', 'three', 'four', 'five', 'six'] + # + # injury_string = f'```md\n# {injury_roll}\n' \ + # f'Details:[3d6 ({d_six_one} {d_six_two} {d_six_three})]\n```\n' + # + # logging.info(f'injury rating: {rating.value}p{games.value}') + # + # injury_list = inj_data[p_ratings[rating.value - 1]][f'p{games.value}'] + # injury_result = injury_list[injury_roll - 3] + # logging.info( + # f'injury rating: {rating.value}p{games.value} / array: {injury_list}[{injury_roll - 2}] / result: {injury_result}') + # + # if isinstance(injury_result, int): + # try: + # await interaction.edit_original_response( + # content=random_gif(random_from_list(['salute', 'press f', 'pay respects'])) + # ) + # except Exception as e: + # logging.info(f'failed to post funny gif') + # injury_string += f'With a roll of {injury_roll}, the injury length is **{injury_result} ' \ + # f'game{"s" if injury_result > 1 else ""}**.' + # elif injury_result == 'REM': + # try: + # await interaction.edit_original_response( + # content=random_gif(random_from_list(['could be worse', 'not too bad'])) + # ) + # except Exception as e: + # logging.info(f'failed to post funny gif') + # injury_string += f'With a roll of {injury_roll}, the injury length is **REMAINDER OF GAME** for batters ' \ + # f'or **FATIGUED** for pitchers' + # else: + # try: + # await interaction.edit_original_response( + # content=random_gif(random_from_list(['it is fine', 'nothing to see here', 'i wasn\'t worried'])) + # ) + # except Exception as e: + # logging.info(f'failed to post funny gif') + # injury_string += f'With a roll of {injury_roll}, the player is **OKAY** - no injury!' + # + # embed = await self.get_dice_embed( + # interaction.channel.name, + # f'Injury roll for {interaction.user.name}', + # injury_string + # ) + # embed.set_footer(text='For pitchers, add their current rest to the injury') + # + # await interaction.channel.send(content=None, embed=embed) + # + # # this_roll = { + # # 'season': self.current['season'], + # # 'week': self.current['week'], + # # 'team_id': team["id"] if team else None, + # # 'roller': interaction.user.id, + # # 'threedsix': d_six_one + d_six_two + d_six_three + # # } + # # self.rolls.append(this_roll) @commands.command(name='c', aliases=['chaos', 'choas'], help='c, chaos, or choas') async def chaos_roll(self, ctx): diff --git a/cogs/players.py b/cogs/players.py index b1a36eb..9a25289 100644 --- a/cogs/players.py +++ b/cogs/players.py @@ -155,12 +155,12 @@ class Players(commands.Cog): # inj_by_week = {'Week 1': [Player Objs], 'Week 2': [Player Objs]} inj_team = {} inj_week = {} - all_injuries = await db_get('players', params=[ - ('season', current['season']), ('is_injured', True) + i_query = await db_get('injuries', params=[ + ('season', current['season']), ('is_active', True), ('sort', 'return-asc') ]) - for x in all_injuries: - player = all_injuries[x] + for x in i_query['injuries']: + player = x['player'] this_team = await get_major_team(player['team']) if this_team['sname'] not in inj_team.keys(): @@ -168,29 +168,28 @@ class Players(commands.Cog): else: inj_team[this_team['sname']].append(player) - if f'Week {player["il_return"][1:3]}' not in inj_week.keys(): - inj_week[f'Week {player["il_return"][1:3]}'] = [player] + if f'Week {x["end_week"]}' not in inj_week.keys(): + inj_week[f'Week {x["end_week"]}'] = [player] else: - inj_week[f'Week {player["il_return"][1:3]}'].append(player) - - inj_by_team = dict(sorted(inj_team.items())) - inj_by_week = dict(sorted(inj_week.items())) + inj_week[f'Week {x["end_week"]}'].append(player) team_embed = discord.Embed(title='Current Injuries by Team') team_embed.description = 'Player Name (Return Date)' team_embed.set_thumbnail(url=LOGO) - for team in inj_by_team: + # for team in inj_by_team: + for team in inj_team: team_string = '' - for player in inj_by_team[team]: + for player in inj_team[team]: team_string += f'{player["name"]} ({player["il_return"]})\n' team_embed.add_field(name=team, value=team_string) week_embed = discord.Embed(title='Current Injuries by Return Week') week_embed.description = 'Player Name (Return Date)' week_embed.set_thumbnail(url=LOGO) - for week in inj_by_week: + # for week in inj_by_week: + for week in inj_week: week_string = '' - for player in inj_by_week[week]: + for player in inj_week[week]: week_string += f'{player["name"]} ({player["il_return"]})\n' week_embed.add_field(name=week, value=week_string) @@ -921,6 +920,11 @@ class Players(commands.Cog): ) return + i_query = await db_get('injuries', params=[('player_id', player['id']), ('is_active', True)]) + if i_query['count'] > 0: + await interaction.edit_original_response(content=f'Hm. It looks like {player["name"]} is already hurt.') + return + out_weeks = math.floor(inj_games / 4) out_games = inj_games % 4 @@ -933,16 +937,21 @@ class Players(commands.Cog): return_date = f'w{return_week:>02}g{return_game:>02}' player['il_return'] = return_date if await patch_player(player): - await db_patch('current', object_id=current['id'], params=[('injury_count', current['injury_count'] + 1)]) embed = get_team_embed(f'Injury Update', team=team) embed.add_field( name=f'{player["name"]}', value=f'{team["sname"]} {player["pos_1"]} {player["name"]} is injured until {return_date}' ) - # await log_injury( - # current, {'player': player, 'type': 'new', 'current_game': this_game, 'injury_length': inj_games} - # ) + await db_post('injuries', payload={ + 'season': current['season'], + 'player_id': player['id'], + 'total_games': inj_games, + 'start_week': this_week if this_game != 4 else this_week + 1, + 'start_game': this_game + 1 if this_game != 4 else 1, + 'end_week': return_week, + 'end_game': return_game + }) await interaction.edit_original_response(content=random_salute_gif()) await send_to_channel(self.bot, 'sba-network-news', content=None, embed=embed) await self.update_injuries(interaction) @@ -962,8 +971,9 @@ class Players(commands.Cog): return player = p_query['players'][0] + i_query = await db_get('injuries', params=[('player_id', player['id']), ('is_active', True)]) - if not player['il_return']: + if not player['il_return'] and i_query['count'] == 0: await interaction.edit_original_response(content='Huh? He isn\'t injured, numb nuts.') return @@ -976,12 +986,9 @@ class Players(commands.Cog): return old_injury = player['il_return'] - await interaction.edit_original_response( - content=f'{player["name"]}\'s return was set for {player["il_return"]}.' - ) view = Confirm(responders=[interaction.user]) await interaction.edit_original_response( - content='Is he eligible to play again?', + content=f'{player["name"]}\'s return was set for {player["il_return"]}. Is he eligible to play again?', view=view ) await view.wait() @@ -994,18 +1001,13 @@ class Players(commands.Cog): ) player['il_return'] = None if await patch_player(player): - await db_patch( - 'current', object_id=current['id'], params=[('injury_count', current['injury_count'] + 1)] - ) embed = get_team_embed(f'Injury Update', team=team) embed.add_field( name=f'{player["name"]}', value=f'{team["sname"]} {player["pos_1"]} {player["name"]}\'s injury ({old_injury}) has ended' ) - # await log_injury( - # current, {'player': player, 'type': 'clear', 'current_game': None, 'injury_length': None} - # ) + await db_patch('injuries', object_id=i_query['injuries'][0]['id'], params=[('is_active', False)]) await interaction.edit_original_response( content=random_conf_gif(), view=None @@ -1024,22 +1026,15 @@ class Players(commands.Cog): help='Links for league resources') async def scorecard_command(self, ctx): await ctx.send( - '***S C O R E C A R D S***\n' - '**OG Card**:\n\n' - '**S6 PCD**:\n\n' - '**Foxx\'s**:\n\n' - '**Josef\'s**:\n\n\n' - '***R E F E R E N C E S***\n' - '**Rules Reference**:\n\n' - '**League Guidelines**:\n\n' - '**Scouting Reference**:\n' + '# SCORECARD\n' + '\n' + '# REFERENCES\n' + '**Rules Reference**:\n\n' + '**League Guidelines**:\n\n' + '**Scouting Reference**:\n' ) @commands.command(name='rest', help='Pitcher rest charts', hidden=True) @@ -2080,9 +2075,8 @@ class Players(commands.Cog): @app_commands.command(name='injury', description='Make an injury check; rating = left of "p", games = right') @app_commands.guilds(discord.Object(id=os.environ.get('GUILD_ID'))) @app_commands.choices(games=[ - Choice(name='86', value=86), - Choice(name='80', value=80), Choice(name='70', value=70), + Choice(name='65', value=65), Choice(name='60', value=60), Choice(name='50', value=50), Choice(name='40', value=40), @@ -2107,64 +2101,58 @@ class Players(commands.Cog): inj_data = { 'one': { - 'p86': ['OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'REM', 'REM', 1, 1, 2, 2, 3, 3, 4, 5], - 'p80': [2, 2, 'OK', 'REM', 1, 2, 3, 3, 4, 4, 5, 5, 6, 8, 12, 16], - 'p70': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 5, 6, 6, 8, 12, 16, 20, 20], - 'p60': ['OK', 'REM', 1, 2, 3, 4, 5, 6, 6, 8, 12, 12, 16, 20, 20, 'OK'], - 'p50': ['OK', 1, 2, 3, 4, 5, 6, 8, 8, 12, 12, 16, 20, 30, 'REM', 'OK'], - 'p40': ['OK', 5, 1, 3, 5, 6, 8, 12, 12, 16, 20, 30, 4, 2, 'REM', 'OK'], - 'p30': ['OK', 1, 2, 5, 6, 8, 12, 16, 20, 30, 12, 8, 4, 3, 'REM', 'OK'], - 'p20': ['OK', 1, 2, 5, 6, 12, 12, 30, 20, 16, 16, 8, 4, 3, 'REM', 'OK'] + 'p70': ['OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'REM', 'REM', 1, 1, 2, 2, 3, 3, 4, 4], + 'p65': [2, 2, 'OK', 'REM', 1, 2, 3, 3, 4, 4, 4, 4, 5, 6, 8, 12], + 'p60': ['OK', 'OK', 'REM', 1, 2, 3, 4, 4, 4, 5, 5, 6, 8, 12, 16, 16], + 'p50': ['OK', 'REM', 1, 2, 3, 4, 4, 5, 5, 6, 8, 8, 12, 16, 16, 'OK'], + 'p40': ['OK', 1, 2, 3, 4, 4, 5, 6, 6, 8, 8, 12, 16, 24, 'REM', 'OK'], + 'p30': ['OK', 4, 1, 3, 4, 5, 6, 8, 8, 12, 16, 24, 4, 2, 'REM', 'OK'], + 'p20': ['OK', 1, 2, 4, 5, 8, 8, 24, 16, 12, 12, 6, 4, 3, 'REM', 'OK'] }, 'two': { - 'p86': [4, 3, 2, 2, 1, 1, 'REM', 'OK', 'REM', 'OK', 2, 1, 2, 2, 3, 5], - 'p80': [12, 6, 4, 2, 2, 'OK', 1, 'OK', 'REM', 1, 'REM', 2, 3, 5, 8, 16], - 'p70': [1, 3, 4, 6, 2, 2, 'OK', 1, 3, 'REM', 4, 5, 8, 12, 16, 3], - 'p60': [5, 'OK', 'OK', 'REM', 1, 2, 5, 3, 4, 6, 4, 8, 12, 16, 16, 'OK'], - 'p50': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 6, 5, 8, 12, 16, 20, 20, 'OK'], - 'p40': ['OK', 'REM', 1, 2, 3, 4, 5, 6, 8, 6, 12, 16, 20, 30, 'REM', 'OK'], - 'p30': ['OK', 1, 2, 4, 5, 6, 8, 6, 12, 16, 8, 20, 30, 3, 5, 'REM'], - 'p20': ['OK', 1, 4, 5, 6, 6, 8, 8, 16, 12, 20, 30, 12, 3, 2, 'REM'] + 'p70': [4, 3, 2, 2, 1, 1, 'REM', 'OK', 'REM', 'OK', 2, 1, 2, 2, 3, 4], + 'p65': [8, 5, 4, 2, 2, 'OK', 1, 'OK', 'REM', 1, 'REM', 2, 3, 4, 6, 12], + 'p60': [1, 3, 4, 5, 2, 2, 'OK', 1, 3, 'REM', 4, 4, 6, 8, 12, 3], + 'p50': [4, 'OK', 'OK', 'REM', 1, 2, 4, 3, 4, 5, 4, 6, 8, 12, 12, 'OK'], + 'p40': ['OK', 'OK', 'REM', 1, 2, 3, 4, 4, 5, 4, 6, 8, 12, 16, 16, 'OK'], + 'p30': ['OK', 'REM', 1, 2, 3, 4, 4, 5, 6, 5, 8, 12, 16, 24, 'REM', 'OK'], + 'p20': ['OK', 1, 4, 4, 5, 5, 6, 6, 12, 8, 16, 24, 8, 3, 2, 'REM'] }, 'three': { - 'p86': [], - 'p80': ['OK', 'OK', 'REM', 1, 3, 'OK', 'REM', 1, 2, 1, 2, 3, 4, 5, 6, 'REM'], - 'p70': ['OK', 6, 'OK', 'REM', 1, 2, 2, 3, 4, 5, 1, 3, 6, 8, 12, 'REM'], - 'p60': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 6, 4, 5, 8, 12, 12, 16, 'REM'], - 'p50': ['OK', 1, 1, 2, 3, 4, 5, 6, 8, 6, 8, 12, 12, 16, 5, 'REM'], - 'p40': ['OK', 1, 2, 3, 4, 6, 5, 8, 6, 8, 12, 12, 16, 20, 1, 'REM'], - 'p30': ['OK', 2, 3, 4, 5, 8, 6, 8, 12, 12, 16, 6, 20, 30, 1, 'REM'], - 'p20': ['OK', 1, 2, 4, 5, 12, 12, 8, 6, 16, 8, 20, 30, 3, 5, 'REM'] + 'p70': [], + 'p65': ['OK', 'OK', 'REM', 1, 3, 'OK', 'REM', 1, 2, 1, 2, 3, 4, 4, 5, 'REM'], + 'p60': ['OK', 5, 'OK', 'REM', 1, 2, 2, 3, 4, 4, 1, 3, 5, 6, 8, 'REM'], + 'p50': ['OK', 'OK', 'REM', 1, 2, 3, 4, 4, 5, 4, 4, 6, 8, 8, 12, 'REM'], + 'p40': ['OK', 1, 1, 2, 3, 4, 4, 5, 6, 5, 6, 8, 8, 12, 4, 'REM'], + 'p30': ['OK', 1, 2, 3, 4, 5, 4, 6, 5, 6, 8, 8, 12, 16, 1, 'REM'], + 'p20': ['OK', 1, 2, 4, 4, 8, 8, 6, 5, 12, 6, 16, 24, 3, 4, 'REM'] }, 'four': { - 'p86': [], - 'p80': [], - 'p70': ['OK', 'OK', 'REM', 3, 3, 'OK', 'REM', 1, 2, 1, 4, 5, 6, 8, 12, 'REM'], - 'p60': ['OK', 8, 4, 'OK', 'REM', 1, 2, 4, 5, 3, 6, 3, 8, 12, 16, 'REM'], - 'p50': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 6, 4, 5, 8, 12, 12, 16, 'REM'], - 'p40': ['OK', 1, 1, 2, 3, 4, 5, 6, 8, 6, 8, 12, 12, 16, 5, 'REM'], - 'p30': ['OK', 'REM', 2, 3, 4, 5, 6, 6, 8, 8, 16, 12, 12, 1, 20, 'REM'], - 'p20': ['OK', 1, 2, 3, 4, 6, 5, 8, 6, 8, 16, 12, 12, 20, 1, 'REM'] + 'p70': [], + 'p65': [], + 'p60': ['OK', 'OK', 'REM', 3, 3, 'OK', 'REM', 1, 2, 1, 4, 4, 5, 6, 8, 'REM'], + 'p50': ['OK', 6, 4, 'OK', 'REM', 1, 2, 4, 4, 3, 5, 3, 6, 8, 12, 'REM'], + 'p40': ['OK', 'OK', 'REM', 1, 2, 3, 4, 4, 5, 4, 4, 6, 8, 8, 12, 'REM'], + 'p30': ['OK', 1, 1, 2, 3, 4, 4, 5, 6, 5, 6, 8, 8, 12, 4, 'REM'], + 'p20': ['OK', 1, 2, 3, 4, 5, 4, 6, 5, 6, 12, 8, 8, 16, 1, 'REM'] }, 'five': { - 'p86': [], - 'p80': [], 'p70': [], - 'p60': ['OK', 'OK', 'REM', 1, 1, 'OK', 'REM', 3, 2, 4, 5, 6, 8, 6, 12, 16], - 'p50': ['OK', 8, 8, 'OK', 1, 3, 2, 4, 5, 6, 'REM', 3, 12, 8, 16, 1], - 'p40': ['OK', 'OK', 'REM', 5, 1, 2, 6, 4, 8, 3, 5, 12, 6, 8, 16, 'REM'], - 'p30': ['OK', 'REM', 2, 3, 5, 4, 6, 5, 8, 6, 12, 8, 3, 1, 16, 'REM'], - 'p20': ['OK', 'REM', 2, 3, 5, 4, 6, 5, 8, 6, 12, 8, 12, 1, 16, 'REM'] + 'p65': [], + 'p60': ['OK', 'REM', 'REM', 'REM', 3, 'OK', 1, 'REM', 2, 1, 'OK', 4, 5, 2, 6, 8], + 'p50': ['OK', 'OK', 'REM', 1, 1, 'OK', 'REM', 3, 2, 4, 4, 5, 5, 6, 8, 12], + 'p40': ['OK', 6, 6, 'OK', 1, 3, 2, 4, 4, 5, 'REM', 3, 8, 6, 12, 1], + 'p30': ['OK', 'OK', 'REM', 4, 1, 2, 5, 4, 6, 3, 4, 8, 5, 6, 12, 'REM'], + 'p20': ['OK', 'REM', 2, 3, 4, 4, 5, 4, 6, 5, 8, 6, 8, 1, 12, 'REM'] }, 'six': { - 'p86': [], - 'p80': [], 'p70': [], + 'p65': [], 'p60': [], - 'p50': ['OK', 8, 3, 'OK', 1, 3, 2, 4, 5, 6, 'REM', 8, 12, 3, 16, 1], - 'p40': ['OK', 'OK', 'REM', 5, 1, 3, 8, 4, 6, 2, 5, 12, 3, 4, 16, 'REM'], - 'p30': ['OK', 'REM', 4, 5, 2, 3, 6, 4, 8, 5, 12, 6, 3, 1, 16, 'REM'], - 'p20': ['OK', 'REM', 2, 3, 5, 4, 6, 5, 8, 6, 12, 8, 12, 1, 16, 'REM'] + 'p50': [], + 'p40': ['OK', 6, 6, 'OK', 1, 3, 2, 4, 4, 5, 'REM', 3, 8, 6, 1, 12], + 'p30': ['OK', 'OK', 'REM', 5, 1, 3, 6, 4, 5, 2, 4, 8, 3, 5, 12, 'REM'], + 'p20': ['OK', 'REM', 4, 6, 2, 3, 6, 4, 8, 5, 5, 6, 3, 1, 12, 'REM'] } } p_ratings = ['one', 'two', 'three', 'four', 'five', 'six'] @@ -2181,7 +2169,7 @@ class Players(commands.Cog): if isinstance(injury_result, int): try: await interaction.edit_original_response( - content=random_gif(random_from_list(['salute', 'press f', 'pay respects'])) + content=random_gif(random_from_list(['salute', 'press f', 'pay respects', 'well shit'])) ) except Exception as e: logging.info(f'failed to post funny gif') diff --git a/helpers.py b/helpers.py index f82f5c7..3037880 100644 --- a/helpers.py +++ b/helpers.py @@ -823,6 +823,9 @@ async def get_player_embed(player, current, ctx=None, season=None): ('season', current['season']), ('week_start', current['week']), ('week_end', current['week'] + 1), ('player_id', player['id']) ]) + d_query = await db_get('draftpicks', params=[ + ('season', current['season']), ('player_id', player['id']) + ]) for x in t_query['transactions']: if x['week'] == current['week']: embed.add_field(name='Last Week', value=f'{x["oldteam"]["sname"]}') @@ -861,6 +864,12 @@ async def get_player_embed(player, current, ctx=None, season=None): if player['demotion_week'] is not None: if player['demotion_week'] > current['week']: embed.add_field(name='Dem Week', value=player["demotion_week"]) + if d_query['count'] > 0: + pick = d_query['picks'][0] + num = pick["overall"] % 16 + if num == 0: + num = 16 + embed.add_field(name='Draft Pick', value=f'{pick["round"]}.{num} ({pick["owner"]["abbrev"]})') b, p = None, None batting_string = None @@ -994,7 +1003,9 @@ async def create_channel( async def get_major_team(team): - if 'Il' in team['abbrev'][len(team['abbrev']) - 2:].lower(): + if team['abbrev'][-3:] == 'MiL': + return await get_team_by_abbrev(team['abbrev'][:-3], team['season']) + elif team['abbrev'][-2:] == 'IL': return await get_team_by_abbrev(team['abbrev'][:-2], team['season']) else: return team