diff --git a/docs/source/guides/navigators.rst b/docs/source/guides/navigators.rst index a88ef338..a179add0 100644 --- a/docs/source/guides/navigators.rst +++ b/docs/source/guides/navigators.rst @@ -35,11 +35,18 @@ and using the ``send()`` method to send the navigator to a channel, or as a resp # If the bot is mentioned if me.id in event.message.user_mentions_ids: embed = hikari.Embed(title="I'm the second page!", description="Also an embed!") + + # A Page object can be used to further customize the page payload if a single embed or str is not enough. + page = nav.Page(content="I'm the last page!", embed=hikari.Embed(title="I also have an embed!")) + # The list of pages this navigator should paginate through - pages = ["I'm the first page!", embed, "I'm the last page!"] + # This should be a list that contains 'str', 'hikari.Embed', and 'nav.Page' objects. + pages = ["I'm the first page!", embed, page] + # Define our navigator and pass in our list of pages navigator = nav.NavigatorView(pages=pages) - # You may also pass an interaction object to this function + + # You may also pass an interaction or miru context to this function await navigator.send(event.channel_id) @@ -97,9 +104,11 @@ You may use any mix of the built-in and custom navigation buttons in your naviga if me.id in event.message.user_mentions_ids: embed = hikari.Embed(title="I'm the second page!", description="Also an embed!") pages = ["I'm a customized navigator!", embed, "I'm the last page!"] + # Define our custom buttons for this navigator, keep in mind the order # All navigator buttons MUST subclass nav.NavButton buttons = [nav.PrevButton(), nav.StopButton(), nav.NextButton(), MyNavButton()] + # Pass our list of NavButton to the navigator navigator = nav.NavigatorView(pages=pages, buttons=buttons) diff --git a/examples/navigator.py b/examples/navigator.py index a4458697..1bd66713 100644 --- a/examples/navigator.py +++ b/examples/navigator.py @@ -39,10 +39,17 @@ async def navigator(event: hikari.GuildMessageCreateEvent) -> None: # If the bot is mentioned if me.id in event.message.user_mentions_ids: embed = hikari.Embed(title="I'm the second page!", description="Also an embed!") - pages = ["I'm the first page!", embed, "I'm the last page!"] + + # You can also pass a Page object to the navigator to create customized page payloads. + page = nav.Page(content="I'm the last page!", embed=hikari.Embed(title="I also have an embed!")) + + # 'pages' should be a list that contains 'str', 'hikari.Embed', and 'nav.Page' objects. + pages = ["I'm the first page!", embed, page] + # Define our navigator and pass in our list of pages navigator = nav.NavigatorView(pages=pages) - # You may also pass an interaction object to this function + + # You may also pass an interaction or miru context to this function await navigator.send(event.channel_id) # Otherwise we annoy everyone with our custom navigator instead diff --git a/miru/ext/nav/navigator.py b/miru/ext/nav/navigator.py index c1406dd4..ac3e73be 100644 --- a/miru/ext/nav/navigator.py +++ b/miru/ext/nav/navigator.py @@ -24,7 +24,7 @@ class NavigatorView(View): Parameters ---------- pages : List[Union[str, hikari.Embed, Sequence[hikari.Embed], Page]] - A list of strings or embeds that this navigator should paginate. + A list of strings, embeds or page objects that this navigator should paginate. buttons : Optional[List[NavButton[NavigatorViewT]]], optional A list of navigation buttons to override the default ones with, by default None timeout : Optional[float], optional @@ -231,7 +231,7 @@ async def swap_pages( context : Context The context object that should be used to send the updated pages new_pages : Sequence[Union[str, Embed, Sequence[Embed] | Page]] - The new pages to swap to + The new sequence of pages to swap to start_at : int, optional The page to start at, by default 0 """