mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Fix http errors for interaction deferring and message changes (#6229)
This commit is contained in:
parent
dbb91dfce8
commit
100de11ce6
@ -37,6 +37,7 @@ class _GenericButton(discord.ui.Button):
|
||||
self.func = func
|
||||
|
||||
async def callback(self, interaction: discord.Interaction):
|
||||
await interaction.response.defer()
|
||||
ctx = self.view.ctx
|
||||
pages = self.view.source.entries
|
||||
controls = None
|
||||
@ -52,7 +53,6 @@ class _GenericButton(discord.ui.Button):
|
||||
await self.func(ctx, pages, controls, message, page, timeout, emoji)
|
||||
except Exception:
|
||||
pass
|
||||
await interaction.response.defer()
|
||||
|
||||
|
||||
async def menu(
|
||||
|
||||
@ -193,14 +193,18 @@ class SimpleMenu(discord.ui.View):
|
||||
return self._source
|
||||
|
||||
async def on_timeout(self):
|
||||
if self.delete_after_timeout and not self.message.flags.ephemeral:
|
||||
await self.message.delete()
|
||||
elif self.disable_after_timeout:
|
||||
for child in self.children:
|
||||
child.disabled = True
|
||||
await self.message.edit(view=self)
|
||||
else:
|
||||
await self.message.edit(view=None)
|
||||
try:
|
||||
if self.delete_after_timeout and not self.message.flags.ephemeral:
|
||||
await self.message.delete()
|
||||
elif self.disable_after_timeout:
|
||||
for child in self.children:
|
||||
child.disabled = True
|
||||
await self.message.edit(view=self)
|
||||
else:
|
||||
await self.message.edit(view=None)
|
||||
except discord.HTTPException:
|
||||
# message could no longer be there or we may not be able to edit/delete it anymore
|
||||
pass
|
||||
|
||||
def _get_select_menu(self):
|
||||
# handles modifying the select menu if more than 25 pages are provided
|
||||
@ -523,9 +527,14 @@ class ConfirmView(discord.ui.View):
|
||||
if self.disable_buttons:
|
||||
self.confirm_button.disabled = True
|
||||
self.dismiss_button.disabled = True
|
||||
await self.message.edit(view=self)
|
||||
view = self
|
||||
else:
|
||||
await self.message.edit(view=None)
|
||||
view = None
|
||||
try:
|
||||
await self.message.edit(view=view)
|
||||
except discord.HTTPException:
|
||||
# message could no longer be there or we may not be able to edit it anymore
|
||||
pass
|
||||
|
||||
@discord.ui.button(label=_("Yes"), style=discord.ButtonStyle.green)
|
||||
async def confirm_button(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user