Screen API Reference#
- class miru.ext.menu.screen.Screen(menu: Menu)[source]#
Bases:
ABCA screen in a menu. Acts similarly to a View, although it is not a subclass of it.
- Parameters:
menu (Menu) – The menu that this screen belongs to.
- add_item(item: ScreenItem) → te.Self[source]#
Adds a new item to the screen.
- Parameters:
item (ViewItem) – The item to be added.
- Raises:
ValueError – ItemHandler already has 25 components attached.
TypeError – Parameter item is not an instance of ViewItem.
ItemAlreadyAttachedError – The item is already attached to this item handler.
- Returns:
The item handler the item was added to.
- Return type:
- abstract async build_content() → ScreenContent[source]#
Build the content payload for this screen. This function is called whenever the screen comes into view.
- Returns:
The content payload for this screen.
- Return type:
- clear_items() → te.Self[source]#
Removes all items from this item handler.
- Returns:
The item handler items were cleared from.
- Return type:
- get_item_by(predicate: Callable[[ScreenItem], bool]) → ScreenItem | None[source]#
Get the first item that matches the given predicate.
- Parameters:
predicate (Callable[[ScreenItem], bool]) – A predicate to match the item.
- Returns:
The item that matched the predicate or None.
- Return type:
Optional[ScreenItem]
- get_item_by_id(custom_id: str) → ScreenItem | None[source]#
Get the first item with the given custom ID.
- Parameters:
custom_id (str) – The custom_id of the component.
- Returns:
The item with the given custom ID or None.
- Return type:
Optional[ScreenItem]
- async on_dispose() → None[source]#
Called when this screen is disposed. This happens when the menu navigates away from this screen.
Note that this is not the same as the screen being removed from the menu, although it can be.
- async on_error(error: Exception) → None[source]#
Called when an exception is raised in build_content or on_dispose.
- Parameters:
error (Exception) – The exception that was raised.
- remove_item(item: ScreenItem) → te.Self[source]#
Removes the specified item from the screen.
- property children: Sequence[ScreenItem]#
The items contained in this screen.
- class miru.ext.menu.screen.ScreenContent(content: hikari.UndefinedOr[t.Any] = UNDEFINED, attachment: hikari.UndefinedOr[hikari.Resourceish] = UNDEFINED, attachments: hikari.UndefinedOr[t.Sequence[hikari.Resourceish]] = UNDEFINED, embed: hikari.UndefinedOr[hikari.Embed] = UNDEFINED, embeds: hikari.UndefinedOr[t.Sequence[hikari.Embed]] = UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = UNDEFINED, user_mentions: hikari.UndefinedOr[t.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool]] = UNDEFINED, role_mentions: hikari.UndefinedOr[t.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool]] = UNDEFINED)[source]#
Bases:
objectThe content payload of an individual menu screen.
- attachment: hikari.UndefinedOr[hikari.Resourceish]#
An attachment to add to this page.
- attachments: hikari.UndefinedOr[t.Sequence[hikari.Resourceish]]#
A sequence of attachments to add to this page.
- content: hikari.UndefinedOr[t.Any]#
The content of the message. Anything passed here will be cast to str.
- embed: hikari.UndefinedOr[hikari.Embed]#
An embed to add to this page.
- embeds: hikari.UndefinedOr[t.Sequence[hikari.Embed]]#
A sequence of embeds to add to this page.
- mentions_everyone: hikari.UndefinedOr[bool]#
If True, mentioning @everyone will be allowed in this page’s message.