Button API Reference#
Button
#
Button(
label: str | None = None,
*,
emoji: hikari.Emoji | str | None = None,
style: InteractiveButtonStylesT = hikari.ButtonStyle.PRIMARY,
disabled: bool = False,
custom_id: str | None = None,
row: int | None = None,
position: int | None = None,
autodefer: (
bool | AutodeferOptions | hikari.UndefinedType
) = hikari.UNDEFINED
)
Bases: InteractiveViewItem
A view component representing an interactive button.
PARAMETER | DESCRIPTION |
---|---|
label |
The button's label
TYPE:
|
emoji |
The emoji present on the button |
style |
The button's style
TYPE:
|
disabled |
A boolean determining if the button should be disabled or not
TYPE:
|
custom_id |
The custom identifier of the button
TYPE:
|
row |
The row the button should be in, leave as None for auto-placement.
TYPE:
|
position |
The position the button should be in within a row, leave as None for auto-placement.
TYPE:
|
autodefer |
The autodefer options for the button. If left
TYPE:
|
RAISES | DESCRIPTION |
---|---|
TypeError
|
If both label and emoji are left empty. |
TypeError
|
if both custom_id and url are provided. |
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.
autodefer
property
#
autodefer: AutodeferOptions | hikari.UndefinedType
Indicates whether the item should be deferred automatically.
If left as UNDEFINED
, the view's autodefer option will be used.
label
property
writable
#
label: str | None
The button's label. This is the text visible on the button.
emoji
property
writable
#
The emoji that should be visible on the button.
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:
|
LinkButton
#
LinkButton(
url: str,
label: str | None = None,
*,
emoji: hikari.Emoji | str | None = None,
disabled: bool = False,
row: int | None = None,
position: int | None = None
)
Bases: ViewItem
A view component representing a link button.
PARAMETER | DESCRIPTION |
---|---|
url |
The URL of the button
TYPE:
|
label |
The button's label
TYPE:
|
emoji |
The emoji present on the button |
disabled |
A boolean determining if the button should be disabled or not
TYPE:
|
row |
The row the button should be in, leave as None for auto-placement.
TYPE:
|
position |
The position the button should be in within a row, leave as None for auto-placement.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
TypeError
|
If both label and emoji are left empty. |
TypeError
|
if both custom_id and url are provided. |
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.
label
property
writable
#
label: str | None
The button's label. This is the text visible on the button.
emoji
property
writable
#
The emoji that should be visible on the button.
button
#
button(
label: str | None = None,
*,
emoji: str | hikari.Emoji | None = None,
custom_id: str | None = None,
style: InteractiveButtonStylesT = hikari.ButtonStyle.PRIMARY,
row: int | None = None,
disabled: bool = False,
autodefer: (
bool | AutodeferOptions | hikari.UndefinedType
) = hikari.UNDEFINED
) -> t.Callable[
[
t.Callable[
[ViewT, ViewContext, Button], t.Awaitable[None]
]
],
DecoratedItem[ViewT, Button],
]
A decorator to transform a coroutine function into a Discord UI Button's callback. This must be inside a subclass of View.
PARAMETER | DESCRIPTION |
---|---|
label |
The button's label
TYPE:
|
emoji |
The emoji shown on the button |
custom_id |
The button's custom identifier
TYPE:
|
style |
The style of the button
TYPE:
|
row |
The row the button should be in, leave as None for auto-placement.
TYPE:
|
disabled |
A boolean determining if the button should be disabled or not
TYPE:
|
autodefer |
The autodefer options for the button. If left
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Callable[[Callable[[ViewT, ViewContext, Button], Awaitable[None]]], DecoratedItem[ViewT, Button]]
|
The decorated callback function. |