Playoff Updates

This commit is contained in:
Cal Corum 2024-06-03 12:08:37 -05:00
parent 5abfc03555
commit 24ee04d7a1
3 changed files with 131 additions and 4 deletions

View File

@ -115,6 +115,32 @@ class Dice(commands.Cog):
# }
# self.rolls.append(this_roll)
@commands.command(name='scout', help='!scout pitcher or !scout batter')
async def scout_ab_roll(self, ctx, roll_type: str):
if roll_type[0] not in ['p', 'b']:
await ctx.send(f'Ya gotta tell me if you\'re rolling for a pitcher or batter')
await ctx.send(random_gif(random_from_list(['come on', 'figure it out', 'fucking christ'])))
return
if roll_type[0] == 'p':
d_six_one = random.randint(4, 6)
else:
d_six_one = random.randint(1, 3)
d_six_two = random.randint(1, 6)
d_six_three = random.randint(1, 6)
d_twenty = random.randint(1, 20)
roll_message = f'```md\n# {d_six_one},{d_six_two + d_six_three},' \
f'{d_twenty}\nDetails:[1d6;2d6;1d20 ({d_six_one} - {d_six_two} {d_six_three} - ' \
f'{d_twenty})]```'
logging.info(f'scouting roll_message: {roll_message}')
await ctx.channel.send(
content=None,
embed=await self.get_dice_embed(ctx.channel, f'At bat roll for {ctx.author.name}', roll_message)
)
if d_six_one == 6 and (d_six_two + d_six_three == 9):
await ctx.send('nice')
@commands.command(name='1d20', aliases=['d20'], help='1d20 or d20')
async def dtwenty_roll(self, ctx):
"""

View File

@ -86,7 +86,7 @@ class Owner(commands.Cog):
@commands.command()
@commands.is_owner()
async def sync(self, ctx: Context, guilds: Greedy[Object], spec: Optional[Literal['~', "*"]] = None) -> None:
async def sync(self, ctx: Context, guilds: Greedy[Object], spec: Optional[Literal['~', "*", '!']] = None) -> None:
"""
!sync -> global sync
!sync ~ -> sync current guild
@ -99,6 +99,10 @@ class Owner(commands.Cog):
elif spec == "*":
ctx.bot.tree.copy_global_to(guild=ctx.guild)
fmt = await ctx.bot.tree.sync(guild=ctx.guild)
elif spec == '!':
ctx.bot.tree.clear_commands(guild=ctx.guild)
await ctx.send(f'Cleared all local commands.')
fmt = await ctx.bot.tree.sync(guild=ctx.guild)
else:
fmt = await ctx.bot.tree.sync()

View File

@ -960,7 +960,6 @@ class Players(commands.Cog):
await self.standings_button_loop(ctx, 'wildcard')
@app_commands.command(name='setinjury', description='Set the return date for injured player')
@app_commands.guilds(discord.Object(id=os.environ.get('GUILD_ID')))
@app_commands.describe(
player_name='Name of injured player',
this_week='The current SBa week',
@ -970,6 +969,10 @@ class Players(commands.Cog):
@app_commands.checks.has_any_role(SBA_PLAYERS_ROLE_NAME)
async def set_injury_slash(
self, interaction: discord.Interaction, player_name: str, this_week: int, this_game: int, inj_games: int):
if interaction.guild_id != 613880856032968834:
await interaction.response.send_message(f'This must be run in the SBa server.')
return
await interaction.response.defer()
current = await db_get('current')
@ -1642,7 +1645,6 @@ class Players(commands.Cog):
# )
@app_commands.command(name='branding', description='Update your team branding')
@app_commands.guilds(discord.Object(id=os.environ.get('GUILD_ID')))
@app_commands.rename(
team_image_url='team_logo_url',
mil_team_image_url='minor_league_logo_url',
@ -2113,7 +2115,7 @@ class Players(commands.Cog):
await interaction.edit_original_response(content=score_text)
@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.guilds(discord.Object(id=os.environ.get('GUILD_ID')))
@app_commands.choices(games=[
Choice(name='70', value=70),
Choice(name='65', value=65),
@ -2132,6 +2134,9 @@ class Players(commands.Cog):
])
async def injury_roll_slash(self, interaction: discord.Interaction, rating: Choice[int], games: Choice[int]):
team = None
if interaction.guild_id != 613880856032968834:
await interaction.response.send_message(f'This must be run in the SBa server.')
return
await interaction.response.defer()
d_six_one = random.randint(1, 6)
@ -2251,6 +2256,98 @@ class Players(commands.Cog):
# }
# self.rolls.append(this_roll)
@app_commands.command(name='sba-update-player', description='Crowd-sourcing player updates')
# @app_commands.guilds(discord.Object(id=os.environ.get('GUILD_ID')))
async def update_player_slash(
self, interaction: discord.Interaction, player_id: int, swar: Optional[float] = None,
injury_rating: Optional[str] = None, bbref_id: Optional[str] = None, strat_code: Optional[str] = None,
team_abbrev: Optional[str] = None):
if interaction.guild_id != 613880856032968834:
await interaction.response.send_message(f'This must be run in the SBa server.')
return
await interaction.response.defer()
current = await db_get('current')
new_season = 10
this_team = await get_team_by_owner(current['season'], interaction.user.id)
if not this_team:
await interaction.edit_original_response(content='Hmm...I can\'t find your team. Are you from around here?')
return
if interaction.user.id == 291738770313707521:
await interaction.edit_original_response(
content=random_gif(random.choices(['no', 'go away', 'please leave', 'why are you like this']))
)
return
this_player = await db_get('players', object_id=player_id)
if this_player is None:
await interaction.edit_original_response(
content=f'I do not know who Player ID **{player_id}** is.'
)
return
update_string = ''
if swar is not None:
update_string += f'sWAR: {this_player["wara"]} => {swar}\n'
this_player['wara'] = swar
if injury_rating is not None:
update_string += f'injury_rating: {this_player["injury_rating"]} => {injury_rating}\n'
this_player['injury_rating'] = injury_rating
if bbref_id is not None:
update_string += f'bbref_id: {this_player["bbref_id"]} => {bbref_id}\n'
this_player['bbref_id'] = bbref_id
if strat_code is not None:
update_string += f'strat_code: {this_player["strat_code"]} => {strat_code}\n'
this_player['strat_code'] = strat_code
if team_abbrev is not None:
new_team = await get_team_by_abbrev(team_abbrev, new_season)
if new_team is None:
await interaction.channel.send(
f'I could not find a team with abbrev **{team_abbrev}** for season {new_season}, ignoring team update'
)
return
update_string += f'team_abbrev: {this_player["team"]["abbrev"]} => {team_abbrev}\n'
this_player['team'] = new_team
if len(update_string) == 0:
await interaction.edit_original_response(
content='Hm. Well I guess it\'s the thought that counts. Maybe next time.'
)
return
p_embed = await get_player_embed(this_player, current, interaction, new_season)
p_embed.add_field(name='BBRef ID', value=bbref_id)
view = Confirm(responders=[interaction.user])
await interaction.edit_original_response(
content=f'Here are the updates - should I commit these?',
embed=p_embed,
view=view
)
await view.wait()
if view.value:
if await patch_player(this_player) is not None:
await interaction.edit_original_response(
content=f'{this_player["name"]} has been updated',
embed=p_embed,
view=None
)
await send_to_channel(
self.bot,
'transaction-log',
f'{interaction.user.mention} updated {this_player["name"]}:\n{update_string}'
)
else:
await interaction.edit_original_response(
content=f'Hm. Well I guess it\'s the thought that counts. Maybe next time.',
embed=None,
view=None
)
async def setup(bot):
await bot.add_cog(Players(bot))