Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions discord/ext/pages/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,11 @@ async def respond(
ephemeral: :class:`bool`
Whether the paginator message and its components are ephemeral.
If ``target`` is specified, the ephemeral message content will be ``target_message`` instead.

.. warning::

If your paginator is ephemeral, it cannot have a timeout longer than 15 minutes (and cannot be persistent).

target: Optional[:class:`~discord.abc.Messageable`]
A target where the paginated message should be sent, if different from the original :class:`discord.Interaction`
target_message: :class:`str`
Expand All @@ -775,7 +780,7 @@ async def respond(
if target is not None and not isinstance(target, discord.abc.Messageable):
raise TypeError(f"expected abc.Messageable not {target.__class__!r}")

if ephemeral and self.timeout >= 900 or self.timeout is None:
if ephemeral and (self.timeout >= 900 or self.timeout is None):
raise ValueError(
"paginator responses cannot be ephemeral if the paginator timeout is 15 minutes or greater"
)
Expand All @@ -801,18 +806,17 @@ async def respond(
view=self,
ephemeral=ephemeral,
)
# convert from WebhookMessage to Message reference to bypass 15min webhook token timeout
msg = await msg.channel.fetch_message(msg.id)
# convert from WebhookMessage to Message reference to bypass 15min webhook token timeout (non-ephemeral messages only)
if not ephemeral:
msg = await msg.channel.fetch_message(msg.id)
else:
msg = await interaction.response.send_message(
content=page_content.content,
embeds=page_content.embeds,
view=self,
ephemeral=ephemeral,
)
if isinstance(msg, discord.WebhookMessage):
self.message = await msg.channel.fetch_message(msg.id)
elif isinstance(msg, discord.Message):
if isinstance(msg, (discord.Message, discord.WebhookMessage)):
self.message = msg
elif isinstance(msg, discord.Interaction):
self.message = await msg.original_message()
Expand Down