From dd33315e166fcce7c28065ec56a6378529ba4468 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Thu, 21 Sep 2023 12:43:55 -0400 Subject: [PATCH] fix(suggestions): transferring original interaction for client.get_cog() --- suggestions/suggestions.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/suggestions/suggestions.py b/suggestions/suggestions.py index fb1f656..6c76740 100644 --- a/suggestions/suggestions.py +++ b/suggestions/suggestions.py @@ -598,9 +598,10 @@ class Suggestions(commands.Cog): ) class SuggestionApproveModal(discord.ui.Modal, title="Approving suggestion..."): - def __init__(self, message): + def __init__(self, old_interaction, message): super().__init__() - self.message = message + self.old_interaction: discord.Interaction = old_interaction + self.message: discord.Message = message reason = discord.ui.TextInput( label="Approval Reason", @@ -611,7 +612,7 @@ class SuggestionApproveModal(discord.ui.Modal, title="Approving suggestion..."): ) async def on_submit(self, interaction: discord.Interaction): - cog = interaction.client.get_cog('Suggestions') + cog = self.old_interaction.client.get_cog('Suggestions') if self.reason.value != "": await Suggestions._interaction_finish_suggestion(cog, interaction, self.message, True, self.reason.value) else: @@ -619,9 +620,10 @@ class SuggestionApproveModal(discord.ui.Modal, title="Approving suggestion..."): await interaction.response.send_message(content="Suggestion approved!", ephemeral=True) class SuggestionDenyModal(discord.ui.Modal, title="Denying suggestion..."): - def __init__(self, message): + def __init__(self, old_interaction, message): super().__init__() - self.message = message + self.old_interaction: discord.Interaction = old_interaction + self.message: discord.Message = message reason = discord.ui.TextInput( label="Denial Reason", @@ -632,7 +634,7 @@ class SuggestionDenyModal(discord.ui.Modal, title="Denying suggestion..."): ) async def on_submit(self, interaction: discord.Interaction): - cog = interaction.client.get_cog('Suggestions') + cog = self.old_interaction.client.get_cog('Suggestions') if self.reason.value != "": await Suggestions._interaction_finish_suggestion(cog, interaction, self.message, False, self.reason.value) else: @@ -641,8 +643,8 @@ class SuggestionDenyModal(discord.ui.Modal, title="Denying suggestion..."): @app_commands.context_menu(name="Approve Suggestion") async def approve_context(interaction: discord.Interaction, message: discord.Message): - await interaction.response.send_modal(SuggestionApproveModal(message)) + await interaction.response.send_modal(SuggestionApproveModal(interaction, message)) @app_commands.context_menu(name="Deny Suggestion") async def deny_context(interaction: discord.Interaction, message: discord.Message): - await interaction.response.send_modal(SuggestionDenyModal(message)) + await interaction.response.send_modal(SuggestionDenyModal(interaction, message))