Skip to content

Commit

Permalink
Adjust on_timeout to Pycord-Development/pycord#2297
Browse files Browse the repository at this point in the history
  • Loading branch information
tibue99 committed Dec 23, 2023
1 parent 0daf203 commit b595b94
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions ezcord/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,27 +167,10 @@ async def on_timeout(self) -> None:
"""If ``disable_on_timeout`` is set to ``True``, this will disable all components,
unless the viw has been explicitly stopped.
"""
if not PYCORD:
try:
return await super().on_timeout()

if self.disable_on_timeout:
self.disable_all_items()

# Fixes Pycord's NotFound error if message is ephemeral
# and interaction has already been responded to
try:
message = self.parent or self._message # type: ignore
except AttributeError:
# Older Pycord versions are missing parent attribute
return await super().on_timeout()

if message:
try:
m = await message.edit(view=self)
except (discord.NotFound, discord.HTTPException):
return
if m:
self._message = m
except discord.NotFound:
return


class EzModal(discord.ui.Modal):
Expand Down

0 comments on commit b595b94

Please sign in to comment.