From 65e2c1d93c5474b3e97e0a4227f874cc427b8793 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 18 Aug 2023 16:57:30 -0400 Subject: [PATCH] misc(issues): added original_interaction --- issues/issues.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/issues/issues.py b/issues/issues.py index dff1054..fce5cae 100644 --- a/issues/issues.py +++ b/issues/issues.py @@ -16,45 +16,49 @@ class Issues(commands.Cog): @app_commands.command() async def issuestest(self, interaction: discord.Interaction): color = await self.bot.get_embed_color(None) - await interaction.response.send_message(content="Hello world!", view=self.IssueButtons(color, self), ephemeral=True) + await interaction.response.send_message(content="Hello world!", view=self.IssueButtons(color, self, interaction), ephemeral=True) - async def submit_issue_request(self, interaction: discord.Interaction, embed: discord.Embed): + async def submit_issue_request(self, interaction: discord.Interaction, original_interaction: discord.Interaction, embed: discord.Embed): channel = self.bot.get_channel(self.config.request_channel()) if channel is None: + await original_interaction.edit_original_response(content="Command cancelled.", view=None) await interaction.response.send_message(content=f"The cog is misconfigured, please report this error.", ephemeral=True) try: await channel.send(embed=embed) await interaction.response.send_message(content=f"Issue request sent!", embed=embed, ephemeral=True) except (discord.HTTPException, discord.Forbidden) as error: + await original_interaction.edit_original_response(content="Command cancelled.", view=None) await interaction.response.send_message(content=f"The cog is misconfigured, please report this error.\n```{error}```", ephemeral=True) class IssueButtons(discord.ui.View): - def __init__(self, color, cog_instance): + def __init__(self, color, cog_instance, original_interaction): super().__init__() self.color = color self.cog_instance = cog_instance + self.original_interaction = original_interaction @discord.ui.button(label="Bot Bug", style=discord.ButtonStyle.danger, row=0) async def issue_button_bot_bug(self, interaction: discord.Interaction, button: discord.ui.Button): - await interaction.response.send_modal(Issues.BotBugModal(self.color, self.cog_instance)) + await interaction.response.send_modal(Issues.BotBugModal(self.color, self.cog_instance, self.original_interaction)) @discord.ui.button(label="Cog Bug", style=discord.ButtonStyle.danger, row=1) async def issue_button_cog_bug(self, interaction: discord.Interaction, button: discord.ui.Button): - await interaction.response.send_modal(Issues.BotBugModal(self.color, self.cog_instance)) + await interaction.response.send_modal(Issues.BotBugModal(self.color, self.cog_instance, self.original_interaction)) @discord.ui.button(label="Bot Suggestion", style=discord.ButtonStyle.blurple, row=0) async def issue_button_bot_suggestion(self, interaction: discord.Interaction, button: discord.ui.Button): - await interaction.response.send_modal(Issues.BotBugModal(self.color, self.cog_instance)) + await interaction.response.send_modal(Issues.BotBugModal(self.color, self.cog_instance, self.original_interaction)) @discord.ui.button(label="Cog Suggestion", style=discord.ButtonStyle.blurple, row=1) async def issue_button_cog_suggestion(self, interaction: discord.Interaction, button: discord.ui.Button): - await interaction.response.send_modal(Issues.BotBugModal(self.color, self.cog_instance)) + await interaction.response.send_modal(Issues.BotBugModal(self.color, self.cog_instance, self.original_interaction)) class BotBugModal(discord.ui.Modal, title="Creating issue..."): - def __init__(self, color, cog_instance): + def __init__(self, color, cog_instance, original_interaction): super().__init__() self.color = color self.cog_instance = cog_instance + self.original_interaction = original_interaction bug_description = discord.ui.TextInput( label="Describe the bug", @@ -97,4 +101,4 @@ class Issues(commands.Cog): else: username = f"{interaction.user.name}#{interaction.user.discriminator}" embed.set_footer(text=f"Submitted by {username} ({interaction.user.id})", icon_url=interaction.user.display_avatar.url) - await self.cog_instance.submit_issue_request(interaction=interaction, embed=embed) + await self.cog_instance.submit_issue_request(interaction=interaction, original_interaction=self.original_interaction, embed=embed)