mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -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
|
self.func = func
|
||||||
|
|
||||||
async def callback(self, interaction: discord.Interaction):
|
async def callback(self, interaction: discord.Interaction):
|
||||||
|
await interaction.response.defer()
|
||||||
ctx = self.view.ctx
|
ctx = self.view.ctx
|
||||||
pages = self.view.source.entries
|
pages = self.view.source.entries
|
||||||
controls = None
|
controls = None
|
||||||
@ -52,7 +53,6 @@ class _GenericButton(discord.ui.Button):
|
|||||||
await self.func(ctx, pages, controls, message, page, timeout, emoji)
|
await self.func(ctx, pages, controls, message, page, timeout, emoji)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
await interaction.response.defer()
|
|
||||||
|
|
||||||
|
|
||||||
async def menu(
|
async def menu(
|
||||||
|
|||||||
@ -193,14 +193,18 @@ class SimpleMenu(discord.ui.View):
|
|||||||
return self._source
|
return self._source
|
||||||
|
|
||||||
async def on_timeout(self):
|
async def on_timeout(self):
|
||||||
if self.delete_after_timeout and not self.message.flags.ephemeral:
|
try:
|
||||||
await self.message.delete()
|
if self.delete_after_timeout and not self.message.flags.ephemeral:
|
||||||
elif self.disable_after_timeout:
|
await self.message.delete()
|
||||||
for child in self.children:
|
elif self.disable_after_timeout:
|
||||||
child.disabled = True
|
for child in self.children:
|
||||||
await self.message.edit(view=self)
|
child.disabled = True
|
||||||
else:
|
await self.message.edit(view=self)
|
||||||
await self.message.edit(view=None)
|
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):
|
def _get_select_menu(self):
|
||||||
# handles modifying the select menu if more than 25 pages are provided
|
# 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:
|
if self.disable_buttons:
|
||||||
self.confirm_button.disabled = True
|
self.confirm_button.disabled = True
|
||||||
self.dismiss_button.disabled = True
|
self.dismiss_button.disabled = True
|
||||||
await self.message.edit(view=self)
|
view = self
|
||||||
else:
|
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)
|
@discord.ui.button(label=_("Yes"), style=discord.ButtonStyle.green)
|
||||||
async def confirm_button(self, interaction: discord.Interaction, button: discord.ui.Button):
|
async def confirm_button(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user