checks_log_interaction ready for use
This commit is contained in:
parent
ee685f1415
commit
86818e322c
@ -348,6 +348,8 @@ class Gameplay(commands.Cog):
|
||||
with Session(engine) as session:
|
||||
this_game, owner_team, this_play = await checks_log_interaction(session, interaction, command_name='flyball')
|
||||
|
||||
await interaction.edit_original_response(content=f'Pow goes teh fly ball!')
|
||||
|
||||
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Gameplay(bot))
|
||||
@ -87,6 +87,7 @@ async def get_lineups_from_sheets(session: Session, sheets, this_game: Game, thi
|
||||
|
||||
|
||||
async def checks_log_interaction(session: Session, interaction: discord.Interaction, command_name: str) -> tuple[Game, Team, Play]:
|
||||
await interaction.response.defer(thinking=True)
|
||||
this_game = get_channel_game_or_none(session, interaction.channel_id)
|
||||
if this_game is None:
|
||||
raise GameNotFoundException('I don\'t see an active game in this channel.')
|
||||
@ -103,7 +104,7 @@ async def checks_log_interaction(session: Session, interaction: discord.Interact
|
||||
logging.exception(f'{command_name} command: No gauntlet team found with abbrev {gauntlet_abbrev}')
|
||||
raise TeamNotFoundException(f'Hm, I was not able to find a gauntlet team for you.')
|
||||
|
||||
if not owner_team['id'] in [this_game.away_team_id, this_game.home_team_id]:
|
||||
if not owner_team.id in [this_game.away_team_id, this_game.home_team_id]:
|
||||
logging.exception(f'{interaction.user.display_name} tried to run a command in Game {this_game.id} when they aren\'t a GM in the game.')
|
||||
raise TeamNotFoundException('Bruh. Only GMs of the active teams can log plays.')
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user