From e7162e0db6fced3f842fd7b4ac958d527100ec8b Mon Sep 17 00:00:00 2001 From: tookender Date: Sun, 25 Aug 2024 21:18:15 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Fix=20interaction=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/config/levelling.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/extensions/config/levelling.py b/extensions/config/levelling.py index 1fb4f98..91893a5 100644 --- a/extensions/config/levelling.py +++ b/extensions/config/levelling.py @@ -125,12 +125,13 @@ async def callback(self, interaction: Interaction): class ConfigLevelling(discord.ui.View): - def __init__(self): + def __init__(self, author: int): super().__init__() + self.author = author self.add_item(ConfigLevellingDropdown()) async def interaction_check(self, interaction: Interaction) -> bool: - if interaction.user and interaction.user.id in (self.ctx.bot.owner_id, self.ctx.author.id): + if interaction.user.id != self.author: return True messages = random.choice(constants.NOT_YOUR_BUTTON) @@ -184,9 +185,9 @@ async def update_message(interaction: Interaction, edit: Optional[bool] = True): ) if not edit: - return await interaction.response.send_message(embed=embed, view=ConfigLevelling()) + return await interaction.response.send_message(embed=embed, view=ConfigLevelling(author=interaction.user.id)) - return await interaction.response.edit_message(embed=embed, view=ConfigLevelling()) + return await interaction.response.edit_message(embed=embed, view=ConfigLevelling(author=interaction.user.id)) except Exception as e: return await interaction.response.send_message(f"An error occurred: {traceback.format_exception(e)}", ephemeral=True)