Speedup Updates
Update initial player pull Move substitution command to app_command
This commit is contained in:
parent
a32c618e21
commit
48b10bfaec
@ -1167,6 +1167,7 @@ class Gameplay(commands.Cog):
|
||||
return
|
||||
|
||||
logging.debug(f'Setting lineup for {ai_team["sname"]} in PD game')
|
||||
logging.info(f'lineups: {all_lineups}')
|
||||
post_lineups(all_lineups)
|
||||
|
||||
await interaction.channel.send(
|
||||
@ -2151,36 +2152,35 @@ class Gameplay(commands.Cog):
|
||||
|
||||
await ctx.send(f'Got it!')
|
||||
|
||||
@commands.hybrid_command(
|
||||
@app_commands.command(
|
||||
name='substitution',
|
||||
help='Make a lineup substitution; Player Name for SBa games / Card ID for PD games',
|
||||
aliases=['sub']
|
||||
description='Make a lineup substitution; Player Name for SBa games / Card ID for PD games'
|
||||
)
|
||||
@app_commands.describe(
|
||||
order_number='Batting order of new player; 10 for pitchers if there is a DH',
|
||||
new_player='For PD game: enter the Card ID (a number); or SBa game: enter the Player Name')
|
||||
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME, PD_PLAYERS_ROLE_NAME)
|
||||
async def substitution_command(
|
||||
self, ctx: commands.Context, team_abbrev: str, new_player: str, order_number: Literal[
|
||||
self, interaction: discord.Interaction, team_abbrev: str, new_player: str, order_number: Literal[
|
||||
'this-spot', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
|
||||
new_pos: Literal['P', 'C', '1B', '2B', '3B', 'SS', 'LF', 'CF', 'RF', 'DH', 'PH', 'PR']):
|
||||
this_game = get_one_game(channel_id=ctx.channel.id, active=True)
|
||||
if not this_game:
|
||||
await ctx.send(f'I dont\'t see an active game in this channel!')
|
||||
this_game, owner_team, this_play = await self.checks_log_interaction(interaction)
|
||||
if False in (this_game, owner_team, this_play):
|
||||
return
|
||||
|
||||
owner_team = await get_game_team(this_game, ctx.author.id)
|
||||
owner_team = await get_game_team(this_game, interaction.user.id)
|
||||
if 'gauntlet' in this_game.game_type:
|
||||
lineup_team = await get_game_team(this_game, team_abbrev=f'Gauntlet-{owner_team["abbrev"]}')
|
||||
else:
|
||||
lineup_team = await get_game_team(this_game, team_abbrev=team_abbrev)
|
||||
|
||||
if owner_team['gmid'] != lineup_team['gmid']:
|
||||
await ctx.send('Bruh. Only GMs of the active teams can set lineups.')
|
||||
await interaction.edit_original_response(content='Bruh. Only GMs of the active teams can set lineups.')
|
||||
return
|
||||
if not lineup_team['id'] in [this_game.away_team_id, this_game.home_team_id]:
|
||||
await ctx.send(f'I do not see {lineup_team["sname"]} in this game. Please check the team abbrev and '
|
||||
f'try again')
|
||||
await interaction.edit_original_response(
|
||||
content=f'I do not see {lineup_team["sname"]} in this game. Please check the team abbrev and try again'
|
||||
)
|
||||
return
|
||||
|
||||
try:
|
||||
@ -2201,16 +2201,20 @@ class Gameplay(commands.Cog):
|
||||
except Exception as e:
|
||||
logging.error(f'Game {this_game} - Could not find player {new_player}')
|
||||
if this_game.is_pd:
|
||||
await ctx.send(f'I could not find card_id {new_player}.')
|
||||
await interaction.edit_original_response(
|
||||
content=f'I could not find card_id {new_player}.'
|
||||
)
|
||||
else:
|
||||
await ctx.send(f'I could not find {new_player.title()}.')
|
||||
await interaction.edit_original_response(
|
||||
content=f'I could not find {new_player.title()}.'
|
||||
)
|
||||
return
|
||||
|
||||
if this_game.game_type in ['major-league', 'hall-of-fame']:
|
||||
legality = await db_post(f'cards/legal-check/ranked?card_id={new_player}')
|
||||
if legality['count'] > 0:
|
||||
il_string = "\n- ".join(legality['bad_cards'])
|
||||
await ctx.send(
|
||||
await interaction.edit_original_response(
|
||||
content=f'It looks like this is a Ranked Legal game and I see the following cards as illegal. '
|
||||
f'Please adjust your lineup and re-submit!\n\n'
|
||||
f'- {il_string}'
|
||||
@ -2238,7 +2242,10 @@ class Gameplay(commands.Cog):
|
||||
|
||||
make_sub(this_lineup)
|
||||
|
||||
await ctx.send(content=None, embed=await self.get_game_state_embed(this_game))
|
||||
await interaction.edit_original_response(
|
||||
content=None,
|
||||
embed=await self.get_game_state_embed(this_game)
|
||||
)
|
||||
|
||||
@commands.hybrid_command(name='gamestate', help='Post the current game state', aliases=['gs'])
|
||||
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME, PD_PLAYERS_ROLE_NAME)
|
||||
|
||||
@ -253,7 +253,7 @@ class Players(commands.Cog):
|
||||
logging.error(f'Still cannot access guild; trying again in 18 hours')
|
||||
return
|
||||
|
||||
all_players = await db_get('players', params=[('flat', True)], timeout=25)
|
||||
all_players = await db_get('players', params=[('flat', True), ('inc_dex', False)], timeout=25)
|
||||
all_cardsets = await db_get('cardsets', params=[('flat', True)])
|
||||
|
||||
[self.player_list.append(x['p_name'].lower()) for x in all_players['players'] if x['p_name'].lower()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user