@@ -370,3 +370,49 @@ async def respond(self, interaction: discord.Interaction, ephemeral: bool = Fals
370
370
elif isinstance (msg , discord .Interaction ):
371
371
self .message = await msg .original_message ()
372
372
return self .message
373
+
374
+ async def update (
375
+ self ,
376
+ interaction : discord .Interaction ,
377
+ pages : List [Union [str , discord .Embed ]],
378
+ show_disabled : Optional [bool ] = None ,
379
+ show_indicator : Optional [bool ] = None ,
380
+ author_check : Optional [bool ] = None ,
381
+ disable_on_timeout : Optional [bool ] = None ,
382
+ custom_view : Optional [discord .ui .View ] = None ,
383
+ timeout : Optional [float ] = None
384
+ ):
385
+ """Updates the paginator. This might be useful if you use a view with :class:`discord.SelectOption`
386
+ and you have a different amount of pages depending on the selected option.
387
+
388
+ Parameters
389
+ ----------
390
+ pages: List[Union[:class:`str`, :class:`discord.Embed`]]
391
+ The list of strings and/or embeds to paginate.
392
+ show_disabled: Optional[:class:`bool`]
393
+ Whether to show disabled buttons.
394
+ show_indicator: Optional[:class:`bool`]
395
+ Whether to show the page indicator.
396
+ author_check: Optional[:class:`bool`]
397
+ Whether only the original user of the command can change pages.
398
+ disable_on_timeout: Optional[:class:`bool`]
399
+ Whether the buttons get disabled when the paginator view times out.
400
+ custom_view: Optional[:class:`discord.ui.View`]
401
+ A custom view whose items are appended below the pagination buttons.
402
+ timeout: Optional[:class:`float`]
403
+ Timeout in seconds from last interaction with the paginator before no longer accepting input.
404
+ """
405
+
406
+ # Update pages and reset current_page to 0 (default)
407
+ self .pages = pages
408
+ self .page_count = len (self .pages ) - 1
409
+ self .current_page = 0
410
+ # Apply config changes, if specified
411
+ self .show_disabled = show_disabled if show_disabled else self .show_disabled
412
+ self .show_indicator = show_indicator if show_indicator else self .show_indicator
413
+ self .usercheck = author_check if author_check else self .usercheck
414
+ self .disable_on_timeout = disable_on_timeout if disable_on_timeout else self .disable_on_timeout
415
+ self .custom_view = custom_view if custom_view else self .custom_view
416
+ self .timeout = timeout if timeout else self .timeout
417
+
418
+ await self .goto_page (interaction , self .current_page )
0 commit comments