Skip to content

Commit e93ecca

Browse files
authored
[ext.pages] Fix for "Unknown Message" errors when using ephemeral paginators (#1224)
* fix for "Unknown Message" errors when using an ephemeral paginator after an ephemeral defer * spelling error
1 parent 1eebe96 commit e93ecca

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

discord/ext/pages/pagination.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,11 @@ async def respond(
758758
ephemeral: :class:`bool`
759759
Whether the paginator message and its components are ephemeral.
760760
If ``target`` is specified, the ephemeral message content will be ``target_message`` instead.
761+
762+
.. warning::
763+
764+
If your paginator is ephemeral, it cannot have a timeout longer than 15 minutes (and cannot be persistent).
765+
761766
target: Optional[:class:`~discord.abc.Messageable`]
762767
A target where the paginated message should be sent, if different from the original :class:`discord.Interaction`
763768
target_message: :class:`str`
@@ -775,7 +780,7 @@ async def respond(
775780
if target is not None and not isinstance(target, discord.abc.Messageable):
776781
raise TypeError(f"expected abc.Messageable not {target.__class__!r}")
777782

778-
if ephemeral and self.timeout >= 900 or self.timeout is None:
783+
if ephemeral and (self.timeout >= 900 or self.timeout is None):
779784
raise ValueError(
780785
"paginator responses cannot be ephemeral if the paginator timeout is 15 minutes or greater"
781786
)
@@ -801,18 +806,17 @@ async def respond(
801806
view=self,
802807
ephemeral=ephemeral,
803808
)
804-
# convert from WebhookMessage to Message reference to bypass 15min webhook token timeout
805-
msg = await msg.channel.fetch_message(msg.id)
809+
# convert from WebhookMessage to Message reference to bypass 15min webhook token timeout (non-ephemeral messages only)
810+
if not ephemeral:
811+
msg = await msg.channel.fetch_message(msg.id)
806812
else:
807813
msg = await interaction.response.send_message(
808814
content=page_content.content,
809815
embeds=page_content.embeds,
810816
view=self,
811817
ephemeral=ephemeral,
812818
)
813-
if isinstance(msg, discord.WebhookMessage):
814-
self.message = await msg.channel.fetch_message(msg.id)
815-
elif isinstance(msg, discord.Message):
819+
if isinstance(msg, (discord.Message, discord.WebhookMessage)):
816820
self.message = msg
817821
elif isinstance(msg, discord.Interaction):
818822
self.message = await msg.original_message()

0 commit comments

Comments
 (0)