Skip to content

Commit

Permalink
make PaginatorMenu and Paginator.update use interaction routes for up…
Browse files Browse the repository at this point in the history
…dating messages, matching the recent changes made by #1227 (#1267)

fixes #1265
  • Loading branch information
krittick authored Apr 15, 2022
1 parent 8f64303 commit 9b3618a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion discord/ext/pages/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ async def update(
timeout: Optional[float] = None,
custom_buttons: Optional[List[PaginatorButton]] = None,
trigger_on_display: Optional[bool] = None,
interaction: Optional[discord.Interaction] = None,
):
"""Updates the existing :class:`Paginator` instance with the provided options.
Expand Down Expand Up @@ -432,6 +433,9 @@ async def update(
trigger_on_display: :class:`bool`
Whether to automatically trigger the callback associated with a `Page` whenever it is displayed.
Has no effect if no callback exists for a `Page`.
interaction: Optional[:class:`discord.Interaction`]
The interaction to use when updating the paginator. If not provided, the paginator will be updated
by using its stored :attr:`message` attribute instead.
"""

# Update pages and reset current_page to 0 (default)
Expand Down Expand Up @@ -460,7 +464,7 @@ async def update(
self.buttons = {}
self.add_default_buttons()

await self.goto_page(self.current_page)
await self.goto_page(self.current_page, interaction=interaction)

async def on_timeout(self) -> None:
"""Disables all buttons when the view times out."""
Expand Down Expand Up @@ -1023,6 +1027,15 @@ def __init__(
super().__init__(placeholder=placeholder, max_values=1, min_values=1, options=opts, custom_id=custom_id)

async def callback(self, interaction: discord.Interaction):
"""|coro|
The coroutine that is called when a menu option is selected.
Parameters
-----------
interaction: :class:`discord.Interaction`
The interaction created by selecting the menu option.
"""
selection = self.values[0]
for page_group in self.page_groups:
if selection == page_group.label:
Expand All @@ -1036,4 +1049,5 @@ async def callback(self, interaction: discord.Interaction):
loop_pages=page_group.loop_pages,
custom_view=page_group.custom_view,
custom_buttons=page_group.custom_buttons,
interaction=interaction,
)

0 comments on commit 9b3618a

Please sign in to comment.