Button API Reference#

class miru.button.Button(*, style: ~hikari.components.ButtonStyle = <ButtonStyle.PRIMARY: 1>, label: str | None = None, disabled: bool = False, custom_id: str | None = None, url: str | None = None, emoji: ~hikari.emojis.Emoji | str | None = None, row: int | None = None, position: int | None = None)[source]#

Bases: ViewItem

A view component representing a button.

Parameters:
  • style (hikari.ButtonStyle, optional) – The button’s style, by default hikari.ButtonStyle.PRIMARY

  • label (Optional[str], optional) – The button’s label, by default None

  • disabled (bool, optional) – A boolean determining if the button should be disabled or not, by default False

  • custom_id (Optional[str], optional) – The custom identifier of the button, by default None

  • url (Optional[str], optional) – The URL of the button, by default None

  • emoji (Union[hikari.Emoji, str, None], optional) – The emoji present on the button, by default None

  • row (Optional[int], optional) – The row the button should be in, leave as None for auto-placement.

  • position (Optional[int], optional) – The position the button should be in within a row, leave as None for auto-placement.

Raises:
  • TypeError – If both label and emoji are left empty.

  • TypeError – if both custom_id and url are provided.

property emoji: Emoji | None#

The emoji that should be visible on the button.

property label: str | None#

The button’s label. This is the text visible on the button.

property style: ButtonStyle#

The button’s style.

property type: ComponentType#

The component’s underlying component type.

property url: str | None#

The button’s URL. If specified, the button will turn into a link button, and the style parameter will be ignored.

miru.button.button(*, label: t.Optional[str] = None, custom_id: t.Optional[str] = None, style: hikari.ButtonStyle = <ButtonStyle.PRIMARY: 1>, emoji: t.Optional[t.Union[str, hikari.Emoji]] = None, row: t.Optional[int] = None, disabled: bool = False) t.Callable[[t.Callable[[ViewT, Button, ViewContextT], t.Awaitable[None]]], DecoratedItem[ViewT, Button, ViewContextT]][source]#

A decorator to transform a coroutine function into a Discord UI Button’s callback. This must be inside a subclass of View.

Parameters:
  • label (Optional[str], optional) – The button’s label, by default None

  • custom_id (Optional[str], optional) – The button’s custom identifier, by default None

  • style (hikari.ButtonStyle, optional) – The style of the button, by default hikari.ButtonStyle.PRIMARY

  • emoji (Optional[Union[str, hikari.Emoji]], optional) – The emoji shown on the button, by default None

  • row (Optional[int], optional) – The row the button should be in, leave as None for auto-placement.

  • disabled (bool, optional) – A boolean determining if the button should be disabled or not, by default False

Returns:

The decorated callback function.

Return type:

Callable[[Callable[[ViewT, Button, ViewContextT], Awaitable[None]]], DecoratedItem[ViewT, Button, ViewContextT]]