fix(suggestions): transferring original interaction for client.get_cog()
Some checks reported warnings
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled

This commit is contained in:
Seaswimmer 2023-09-21 12:43:55 -04:00
parent 3a7d4132e0
commit dd33315e16
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -598,9 +598,10 @@ class Suggestions(commands.Cog):
) )
class SuggestionApproveModal(discord.ui.Modal, title="Approving suggestion..."): class SuggestionApproveModal(discord.ui.Modal, title="Approving suggestion..."):
def __init__(self, message): def __init__(self, old_interaction, message):
super().__init__() super().__init__()
self.message = message self.old_interaction: discord.Interaction = old_interaction
self.message: discord.Message = message
reason = discord.ui.TextInput( reason = discord.ui.TextInput(
label="Approval Reason", label="Approval Reason",
@ -611,7 +612,7 @@ class SuggestionApproveModal(discord.ui.Modal, title="Approving suggestion..."):
) )
async def on_submit(self, interaction: discord.Interaction): 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 != "": if self.reason.value != "":
await Suggestions._interaction_finish_suggestion(cog, interaction, self.message, True, self.reason.value) await Suggestions._interaction_finish_suggestion(cog, interaction, self.message, True, self.reason.value)
else: else:
@ -619,9 +620,10 @@ class SuggestionApproveModal(discord.ui.Modal, title="Approving suggestion..."):
await interaction.response.send_message(content="Suggestion approved!", ephemeral=True) await interaction.response.send_message(content="Suggestion approved!", ephemeral=True)
class SuggestionDenyModal(discord.ui.Modal, title="Denying suggestion..."): class SuggestionDenyModal(discord.ui.Modal, title="Denying suggestion..."):
def __init__(self, message): def __init__(self, old_interaction, message):
super().__init__() super().__init__()
self.message = message self.old_interaction: discord.Interaction = old_interaction
self.message: discord.Message = message
reason = discord.ui.TextInput( reason = discord.ui.TextInput(
label="Denial Reason", label="Denial Reason",
@ -632,7 +634,7 @@ class SuggestionDenyModal(discord.ui.Modal, title="Denying suggestion..."):
) )
async def on_submit(self, interaction: discord.Interaction): 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 != "": if self.reason.value != "":
await Suggestions._interaction_finish_suggestion(cog, interaction, self.message, False, self.reason.value) await Suggestions._interaction_finish_suggestion(cog, interaction, self.message, False, self.reason.value)
else: else:
@ -641,8 +643,8 @@ class SuggestionDenyModal(discord.ui.Modal, title="Denying suggestion..."):
@app_commands.context_menu(name="Approve Suggestion") @app_commands.context_menu(name="Approve Suggestion")
async def approve_context(interaction: discord.Interaction, message: discord.Message): 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") @app_commands.context_menu(name="Deny Suggestion")
async def deny_context(interaction: discord.Interaction, message: discord.Message): 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))