Skip to content

Screen API Reference#

ScreenContent #

The content payload of an individual menu screen.

content class-attribute instance-attribute #

The content of the message. Anything passed here will be cast to str.

attachment class-attribute instance-attribute #

An attachment to add to this page.

attachments class-attribute instance-attribute #

A sequence of attachments to add to this page.

embed class-attribute instance-attribute #

An embed to add to this page.

embeds class-attribute instance-attribute #

A sequence of embeds to add to this page.

mentions_everyone class-attribute instance-attribute #

mentions_everyone: hikari.UndefinedOr[bool] = (
    hikari.UNDEFINED
)

If True, mentioning @everyone will be allowed in this page's message.

user_mentions class-attribute instance-attribute #

The set of allowed user mentions in this page's message. Set to True to allow all.

role_mentions class-attribute instance-attribute #

The set of allowed role mentions in this page's message. Set to True to allow all.

Screen #

Screen(menu: Menu)

Bases: abc.ABC

A screen in a menu. Acts similarly to a View, although it is not a subclass of it.

PARAMETER DESCRIPTION
menu

The menu that this screen belongs to.

TYPE: Menu

menu property #

menu: Menu

The menu that this screen belongs to.

children property #

children: t.Sequence[ScreenItem]

The items contained in this screen.

build_content abstractmethod async #

build_content() -> ScreenContent

Build the content payload for this screen. This function is called whenever the screen comes into view.

RETURNS DESCRIPTION
ScreenContent

The content payload for this screen.

on_dispose async #

on_dispose() -> None

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.

on_error async #

on_error(error: Exception) -> None

Called when an exception is raised in build_content or on_dispose.

PARAMETER DESCRIPTION
error

The exception that was raised.

TYPE: Exception

add_item #

add_item(item: ScreenItem) -> te.Self

Adds a new item to the screen.

PARAMETER DESCRIPTION
item

The item to be added.

TYPE: ViewItem

RAISES DESCRIPTION
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 DESCRIPTION
Screen

The item handler the item was added to.

remove_item #

remove_item(item: ScreenItem) -> te.Self

Removes the specified item from the screen.

PARAMETER DESCRIPTION
item

The item to be removed.

TYPE: ViewItem

RETURNS DESCRIPTION
Screen

The item handler the item was removed from.

clear_items #

clear_items() -> te.Self

Removes all items from this item handler.

RETURNS DESCRIPTION
Screen

The item handler items were cleared from.

get_item_by #

get_item_by(
    predicate: t.Callable[[ScreenItem], bool]
) -> ScreenItem | None

Get the first item that matches the given predicate.

PARAMETER DESCRIPTION
predicate

A predicate to match the item.

TYPE: Callable[[ScreenItem], bool]

RETURNS DESCRIPTION
Optional[ScreenItem]

The item that matched the predicate or None.

get_item_by_id #

get_item_by_id(custom_id: str) -> ScreenItem | None

Get the first item with the given custom ID.

PARAMETER DESCRIPTION
custom_id

The custom_id of the component.

TYPE: str

RETURNS DESCRIPTION
Optional[ScreenItem]

The item with the given custom ID or None.