Skip to content

Item ABCs API Reference#

Item #

Item(
    *,
    custom_id: str | None = None,
    row: int | None = None,
    position: int | None = None,
    width: int = 1
)

Bases: abc.ABC, t.Generic[BuilderT, ContextT, HandlerT]

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

position property writable #

position: int | None

The position of the item within the row it occupies.

row property writable #

row: int | None

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

width property #

width: int

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

custom_id property writable #

custom_id: str

The item's custom identifier. This will be used to track the item through interactions and is required for persistent views.

type abstractmethod property #

The component's underlying component type.

ViewItem #

ViewItem(
    *,
    custom_id: str | None = None,
    row: int | None = None,
    position: int | None = None,
    width: int = 1,
    disabled: bool = False
)

Bases: Item['hikari.impl.MessageActionRowBuilder', 'ViewContext', 'View'], abc.ABC

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

row property writable #

row: int | None

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

position property writable #

position: int | None

The position of the item within the row it occupies.

custom_id property writable #

custom_id: str

The item's custom identifier. This will be used to track the item through interactions and is required for persistent views.

width property #

width: int

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

type abstractmethod property #

The component's underlying component type.

view property #

view: View

The view this item is attached to.

disabled property writable #

disabled: bool

Indicates whether the item is disabled or not.

InteractiveViewItem #

InteractiveViewItem(
    *,
    custom_id: str | None = None,
    row: int | None = None,
    position: int | None = None,
    width: int = 1,
    disabled: bool = False,
    autodefer: (
        bool | AutodeferOptions | hikari.UndefinedType
    ) = hikari.UNDEFINED
)

Bases: ViewItem, abc.ABC

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

row property writable #

row: int | None

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

position property writable #

position: int | None

The position of the item within the row it occupies.

custom_id property writable #

custom_id: str

The item's custom identifier. This will be used to track the item through interactions and is required for persistent views.

width property #

width: int

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

type abstractmethod property #

The component's underlying component type.

view property #

view: View

The view this item is attached to.

disabled property writable #

disabled: bool

Indicates whether the item is disabled or not.

autodefer property #

Indicates whether the item should be deferred automatically. If left as UNDEFINED, the view's autodefer option will be used.

callback async #

callback(context: ViewContext) -> None

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

PARAMETER DESCRIPTION
context

The context, proxying the incoming interaction.

TYPE: ViewContextT

ModalItem #

ModalItem(
    *,
    custom_id: str | None = None,
    row: int | None = None,
    position: int | None = None,
    width: int = 1,
    required: bool = False
)

Bases: Item['hikari.impl.ModalActionRowBuilder', 'ModalContext', 'Modal'], abc.ABC

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

row property writable #

row: int | None

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

position property writable #

position: int | None

The position of the item within the row it occupies.

custom_id property writable #

custom_id: str

The item's custom identifier. This will be used to track the item through interactions and is required for persistent views.

width property #

width: int

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

type abstractmethod property #

The component's underlying component type.

modal property #

modal: Modal | None

The modal this item is attached to.

required property writable #

required: bool

Indicates whether the item is required or not.

DecoratedItem #

DecoratedItem(
    item_type: type[ViewItemT],
    callback: t.Callable[
        [ViewT, ViewContext, ViewItemT],
        t.Coroutine[t.Any, t.Any, None],
    ],
    **kwargs: t.Any
)

Bases: t.Generic[ViewT, ViewItemT]

A partial item made using a decorator.

name property #

name: str

The name of the callback this item decorates.

RETURNS DESCRIPTION
str

The name of the callback.

build #

build(view: ViewT) -> ViewItemT

Convert a DecoratedItem into a ViewItem.

PARAMETER DESCRIPTION
view

The view this decorated item is attached to.

TYPE: ViewT

RETURNS DESCRIPTION
ViewItem[ViewT]

The converted item.