Menu API Reference#
- class miru.ext.menu.menu.Menu(*, timeout: t.Optional[t.Union[float, int, datetime.timedelta]] = 300.0, autodefer: bool = True)[source]#
Bases:
ViewA menu that can be used to display multiple nested screens of components.
- Parameters:
timeout (Optional[Union[float, int, datetime.timedelta]], optional) – The duration after which the menu times out, in seconds, by default 300.0
autodefer (bool, optional) – If enabled, interactions will be automatically deferred if not responded to within 2 seconds, by default True
- async on_timeout() → None[source]#
Called when the item handler times out. Override for custom timeout logic.
- async pop(count: int = 1) → None[source]#
Pop ‘count’ screen off the menu stack and display the screen on top of the stack. This can be used to go back to the previous screen(s).
- Parameters:
count (int) – The number of screens to pop off the stack. Defaults to 1
- Raises:
ValueError – Cannot pop less than 1 screen.
ValueError – Cannot pop the last screen.
- async pop_until_root() → None[source]#
Pop all screens off the menu stack until the root screen is reached.
- async push(screen: Screen) → None[source]#
Push a screen onto the menu stack and display it.
- Parameters:
screen (Screen) – The screen to push onto the stack and display.
- async send(starting_screen: Screen, to: t.Union[hikari.SnowflakeishOr[hikari.TextableChannel], hikari.MessageResponseMixin[t.Any], miru.Context[t.Any]], ephemeral: bool = False, responded: bool = False) → None[source]#
Start up the menu, send the starting screen, and start listening for interactions.
- Parameters:
starting_screen (Screen) – The screen to start the menu with.
to (Union[hikari.SnowflakeishOr[hikari.PartialChannel], hikari.MessageResponseMixin[Any], miru.Context]) – The channel, interaction, or miru context to send the menu to.
ephemeral (bool) – If an interaction or context was provided, determines if the navigator will be sent ephemerally or not. This is ignored if a channel was provided, as regular messages cannot be ephemeral.
responded (bool) – If an interaction was provided, determines if the interaction was previously acknowledged or not. This is ignored if a channel or context was provided.
- async update_message(new_content: t.Optional[ScreenContent] = None) → None[source]#
Update the message with the current state of the menu.
- Parameters:
new_content (Optional[ScreenContent], optional) – The new content to use, if left as None, only the components will be updated, by default None