Item API Reference#

class miru.abc.item.DecoratedItem(item: ViewItemT, callback: Callable[[ViewT, ViewItemT, ViewContextT], Awaitable[None]])[source]#

A partial item made using a decorator.

build(view: View) ViewItemT[source]#

Convert a DecoratedItem into a ViewItem.

Parameters:

view (ViewT) – The view this decorated item is attached to.

Returns:

The converted item.

Return type:

ViewItem[ViewT]

property name: str#

The name of the callback this item decorates.

Returns:

The name of the callback.

Return type:

str

class miru.abc.item.Item(*, custom_id: str | None = None, row: int | None = None, position: int | None = None, width: int = 1)[source]#

An abstract base class for all components. Cannot be directly instantiated.

property custom_id: str#

The Discord custom_id of the item.

property position: int | None#

The position of the item within the row it occupies. Leave as None for automatic placement.

property row: int | None#

The row the item should occupy. Leave as None for automatic placement.

abstract property type: ComponentType#

The component’s underlying component type.

property width: int#

The item’s width taken up in a Discord UI action row.

class miru.abc.item.ModalItem(*, custom_id: str | None = None, row: int | None = None, position: int | None = None, width: int = 1, required: bool = False)[source]#

An abstract base class for modal components. Cannot be directly instantiated.

property modal: t.Optional[Modal]#

The modal this item is attached to.

property required: bool#

Indicates whether the item is required or not.

class miru.abc.item.ViewItem(*, custom_id: str | None = None, row: int | None = None, position: int | None = None, width: int = 1, disabled: bool = False)[source]#

An abstract base class for view components. Cannot be directly instantiated.

async callback(context: ViewContextT) None[source]#

The component’s callback, gets called when the component receives an interaction.

Parameters:

context (ViewContextT) – The context, proxying the incoming interaction.

property disabled: bool#

Indicates whether the item is disabled or not.

property view: View#

The view this item is attached to.