Skip to content

Commit 0e66f5b

Browse files
committed
Update docs
1 parent e6a1ca6 commit 0e66f5b

3 files changed

Lines changed: 22 additions & 6 deletions

File tree

docs/source/guides/navigators.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,18 @@ and using the ``send()`` method to send the navigator to a channel, or as a resp
3535
# If the bot is mentioned
3636
if me.id in event.message.user_mentions_ids:
3737
embed = hikari.Embed(title="I'm the second page!", description="Also an embed!")
38+
39+
# A Page object can be used to further customize the page payload if a single embed or str is not enough.
40+
page = nav.Page(content="I'm the last page!", embed=hikari.Embed(title="I also have an embed!"))
41+
3842
# The list of pages this navigator should paginate through
39-
pages = ["I'm the first page!", embed, "I'm the last page!"]
43+
# This should be a list that contains 'str', 'hikari.Embed', and 'nav.Page' objects.
44+
pages = ["I'm the first page!", embed, page]
45+
4046
# Define our navigator and pass in our list of pages
4147
navigator = nav.NavigatorView(pages=pages)
42-
# You may also pass an interaction object to this function
48+
49+
# You may also pass an interaction or miru context to this function
4350
await navigator.send(event.channel_id)
4451

4552

@@ -97,9 +104,11 @@ You may use any mix of the built-in and custom navigation buttons in your naviga
97104
if me.id in event.message.user_mentions_ids:
98105
embed = hikari.Embed(title="I'm the second page!", description="Also an embed!")
99106
pages = ["I'm a customized navigator!", embed, "I'm the last page!"]
107+
100108
# Define our custom buttons for this navigator, keep in mind the order
101109
# All navigator buttons MUST subclass nav.NavButton
102110
buttons = [nav.PrevButton(), nav.StopButton(), nav.NextButton(), MyNavButton()]
111+
103112
# Pass our list of NavButton to the navigator
104113
navigator = nav.NavigatorView(pages=pages, buttons=buttons)
105114

examples/navigator.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,17 @@ async def navigator(event: hikari.GuildMessageCreateEvent) -> None:
3939
# If the bot is mentioned
4040
if me.id in event.message.user_mentions_ids:
4141
embed = hikari.Embed(title="I'm the second page!", description="Also an embed!")
42-
pages = ["I'm the first page!", embed, "I'm the last page!"]
42+
43+
# You can also pass a Page object to the navigator to create customized page payloads.
44+
page = nav.Page(content="I'm the last page!", embed=hikari.Embed(title="I also have an embed!"))
45+
46+
# 'pages' should be a list that contains 'str', 'hikari.Embed', and 'nav.Page' objects.
47+
pages = ["I'm the first page!", embed, page]
48+
4349
# Define our navigator and pass in our list of pages
4450
navigator = nav.NavigatorView(pages=pages)
45-
# You may also pass an interaction object to this function
51+
52+
# You may also pass an interaction or miru context to this function
4653
await navigator.send(event.channel_id)
4754

4855
# Otherwise we annoy everyone with our custom navigator instead

miru/ext/nav/navigator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class NavigatorView(View):
2424
Parameters
2525
----------
2626
pages : List[Union[str, hikari.Embed, Sequence[hikari.Embed], Page]]
27-
A list of strings or embeds that this navigator should paginate.
27+
A list of strings, embeds or page objects that this navigator should paginate.
2828
buttons : Optional[List[NavButton[NavigatorViewT]]], optional
2929
A list of navigation buttons to override the default ones with, by default None
3030
timeout : Optional[float], optional
@@ -231,7 +231,7 @@ async def swap_pages(
231231
context : Context
232232
The context object that should be used to send the updated pages
233233
new_pages : Sequence[Union[str, Embed, Sequence[Embed] | Page]]
234-
The new pages to swap to
234+
The new sequence of pages to swap to
235235
start_at : int, optional
236236
The page to start at, by default 0
237237
"""

0 commit comments

Comments
 (0)