Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hypergonial committed Sep 6, 2023
1 parent e6a1ca6 commit 0e66f5b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
13 changes: 11 additions & 2 deletions docs/source/guides/navigators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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)

Expand Down
11 changes: 9 additions & 2 deletions examples/navigator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions miru/ext/nav/navigator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
"""
Expand Down

0 comments on commit 0e66f5b

Please sign in to comment.