Skip to content

Commit

Permalink
🪲 Bug Fix: Restrict users from deleting multi-prompt images
Browse files Browse the repository at this point in the history
  • Loading branch information
Zingzy committed Apr 11, 2024
1 parent 777aeff commit bf0bfa8
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions cogs/multi_imagine_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,26 @@ async def regerate_4(self, interaction: discord.Interaction, button: discord.ui.

@discord.ui.button(style=discord.ButtonStyle.red, custom_id="multiimagine_delete", emoji="<:delete:1187102382312652800>")
async def delete(self, interaction: discord.Interaction, button: discord.ui.Button):
delete_multi_imagined_prompt_data(interaction.message.id)
try:
data = get_multi_imagined_prompt_data(interaction.message.id)
author_id = data["author"]

try:
author_id = int(author_id)
except:
pass

if interaction.user.id != author_id:
await interaction.response.send_message(embed=discord.Embed(title="Error", description="You can only delete your own images", color=discord.Color.red()), ephemeral=True)
return

await interaction.message.delete()
delete_multi_imagined_prompt_data(interaction.message.id)
await interaction.message.delete()
return

except Exception as e:
print(e)
await interaction.response.send_message(embed=discord.Embed(title="Error Deleting the Image", description=f"{e}", color=discord.Color.red()), ephemeral=True)

@app_commands.command(name="multi-imagine", description="Imagine multiple prompts")
@app_commands.checks.cooldown(1, 30)
Expand Down

0 comments on commit bf0bfa8

Please sign in to comment.