Skip to content

Commit

Permalink
Button Interaction Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoz committed Oct 16, 2024
1 parent 3086116 commit 0ffcdb0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cogs/palgame/battle.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ def create_battle_view(self, pal_data, user, opponent_pal, level, experience, us
return view

async def skill_callback(self, interaction, user, opponent_pal, skill, pal_data, level, experience, user_hp, opponent_hp, user_stamina, opponent_stamina):
if interaction.user.id != user.id:
await interaction.response.send_message("You can't interact with this button.", ephemeral=True)
return

if interaction.response.is_done():
return

Expand Down
8 changes: 8 additions & 0 deletions cogs/palgame/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def create_catch_view(self, pal, user):
butcher_button = Button(style=ButtonStyle.red, label="Butcher")

async def catch_callback(interaction: Interaction):
if interaction.user.id != user.id:
await interaction.response.send_message("You can't interact with this button.", ephemeral=True)
return

if await self.user_has_pal(str(user.id), pal['Name']):
embed = nextcord.Embed(
title="Already Caught!",
Expand All @@ -95,6 +99,10 @@ async def catch_callback(interaction: Interaction):
await interaction.response.edit_message(embed=embed, view=None)

async def butcher_callback(interaction: Interaction):
if interaction.user.id != user.id:
await interaction.response.send_message("You can't interact with this button.", ephemeral=True)
return

points_awarded = random.randint(10, 50)
await add_points(str(user.id), user.name, points_awarded)
embed = nextcord.Embed(
Expand Down

0 comments on commit 0ffcdb0

Please sign in to comment.