Screen Items API Reference#
ScreenItem
#
ScreenItem(
*,
custom_id: str | None = None,
row: int | None = None,
position: int | None = None,
disabled: bool = False,
width: int = 1
)
Bases: miru.abc.ViewItem
, abc.ABC
An abstract base for all screen items.
Screen
requires instances of this class as it's items.
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.
type
abstractmethod
property
#
type: hikari.ComponentType
The component's underlying component type.
InteractiveScreenItem
#
InteractiveScreenItem(
*,
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: miru.abc.InteractiveViewItem
, ScreenItem
An abstract base for all interactive screen items.
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.
type
abstractmethod
property
#
type: hikari.ComponentType
The component's underlying component type.
menu
property
#
menu: Menu
The menu this item is attached to.
This will be the same as view
if the view is a menu.
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.
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:
|
ScreenLinkButton
#
ScreenLinkButton(
url: str,
label: str | None = None,
*,
emoji: hikari.Emoji | str | None = None,
disabled: bool = False,
row: int | None = None,
position: int | None = None
)
Bases: miru.LinkButton
, ScreenItem
A base class for all screen link buttons.
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.
menu
property
#
menu: Menu
The menu this item is attached to.
This will be the same as view
if the view is a menu.
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.
ScreenButton
#
ScreenButton(
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: miru.Button
, InteractiveScreenItem
A base class for all screen buttons.
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.
menu
property
#
menu: Menu
The menu this item is attached to.
This will be the same as view
if the view is a menu.
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:
|
ScreenTextSelect
#
ScreenTextSelect(
*,
options: t.Sequence[
hikari.SelectMenuOption | SelectOption
],
custom_id: str | None = None,
placeholder: str | None = None,
min_values: int = 1,
max_values: int = 1,
disabled: bool = False,
row: int | None = None,
autodefer: (
bool | AutodeferOptions | hikari.UndefinedType
) = hikari.UNDEFINED
)
Bases: miru.TextSelect
, InteractiveScreenItem
A base class for all screen text selects.
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.
menu
property
#
menu: Menu
The menu this item is attached to.
This will be the same as view
if the view is a menu.
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.
placeholder
property
writable
#
placeholder: str | None
The placeholder text that appears before the select menu is clicked.
max_values
property
writable
#
max_values: int
The maximum amount of options a user is allowed to select.
options
property
writable
#
options: t.Sequence[hikari.SelectMenuOption | SelectOption]
The select menu's options.
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:
|
ScreenUserSelect
#
ScreenUserSelect(
*,
custom_id: str | None = None,
placeholder: str | None = None,
min_values: int = 1,
max_values: int = 1,
disabled: bool = False,
row: int | None = None,
autodefer: (
bool | AutodeferOptions | hikari.UndefinedType
) = hikari.UNDEFINED
)
Bases: miru.UserSelect
, InteractiveScreenItem
A base class for all screen user selects.
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.
menu
property
#
menu: Menu
The menu this item is attached to.
This will be the same as view
if the view is a menu.
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.
placeholder
property
writable
#
placeholder: str | None
The placeholder text that appears before the select menu is clicked.
max_values
property
writable
#
max_values: int
The maximum amount of options a user is allowed to select.
values
property
#
The currently selected user objects.
Some users may also be instances of hikari.InteractionMember
, depending on how they were resolved.
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:
|
ScreenRoleSelect
#
ScreenRoleSelect(
*,
custom_id: str | None = None,
placeholder: str | None = None,
min_values: int = 1,
max_values: int = 1,
disabled: bool = False,
row: int | None = None,
autodefer: (
bool | AutodeferOptions | hikari.UndefinedType
) = hikari.UNDEFINED
)
Bases: miru.RoleSelect
, InteractiveScreenItem
A base class for all screen role selects.
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.
menu
property
#
menu: Menu
The menu this item is attached to.
This will be the same as view
if the view is a menu.
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.
placeholder
property
writable
#
placeholder: str | None
The placeholder text that appears before the select menu is clicked.
max_values
property
writable
#
max_values: int
The maximum amount of options a user is allowed to select.
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:
|
ScreenChannelSelect
#
ScreenChannelSelect(
*,
channel_types: t.Sequence[hikari.ChannelType] = (
hikari.ChannelType.GUILD_TEXT
),
custom_id: str | None = None,
placeholder: str | None = None,
min_values: int = 1,
max_values: int = 1,
disabled: bool = False,
row: int | None = None,
autodefer: (
bool | AutodeferOptions | hikari.UndefinedType
) = hikari.UNDEFINED
)
Bases: miru.ChannelSelect
, InteractiveScreenItem
A base class for all screen channel selects.
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.
menu
property
#
menu: Menu
The menu this item is attached to.
This will be the same as view
if the view is a menu.
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.
placeholder
property
writable
#
placeholder: str | None
The placeholder text that appears before the select menu is clicked.
max_values
property
writable
#
max_values: int
The maximum amount of options a user is allowed to select.
channel_types
property
writable
#
channel_types: t.Sequence[hikari.ChannelType]
The valid channel types that can be selected from the select menu.
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:
|
ScreenMentionableSelect
#
ScreenMentionableSelect(
*,
custom_id: str | None = None,
placeholder: str | None = None,
min_values: int = 1,
max_values: int = 1,
disabled: bool = False,
row: int | None = None,
autodefer: (
bool | AutodeferOptions | hikari.UndefinedType
) = hikari.UNDEFINED
)
Bases: miru.MentionableSelect
, InteractiveScreenItem
A base class for all screen mentionable selects.
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.
menu
property
#
menu: Menu
The menu this item is attached to.
This will be the same as view
if the view is a menu.
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.
placeholder
property
writable
#
placeholder: str | None
The placeholder text that appears before the select menu is clicked.
max_values
property
writable
#
max_values: int
The maximum amount of options a user is allowed to select.
values
property
#
values: hikari.ResolvedOptionData | None
The currently selected mentionable objects.
This is returned as a hikari.ResolvedOptionData
object.
You can access each type of mentionable object by using the following attributes:
values.users
- All user objects selectedvalues.roles
- All role objects selectedvalues.channels
- All channel objects selectedvalues.members
- All member objects selected
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:
|
DecoratedScreenItem
#
DecoratedScreenItem(
item_type: type[ScreenItemT],
callback: t.Callable[
[ScreenT, miru.ViewContext, ScreenItemT],
t.Coroutine[t.Any, t.Any, None],
],
**kwargs: t.Any
)
Bases: t.Generic[ScreenT, ScreenItemT]
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
#
Convert a DecoratedScreenItem into a ViewItem.
PARAMETER | DESCRIPTION |
---|---|
screen |
The screen this decorated item is attached to.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ScreenItemT
|
The converted item. |
button
#
button(
*,
label: str | None = None,
custom_id: str | None = None,
style: InteractiveButtonStylesT = hikari.ButtonStyle.PRIMARY,
emoji: str | hikari.Emoji | None = None,
row: int | None = None,
disabled: bool = False,
autodefer: (
bool | miru.AutodeferOptions | hikari.UndefinedType
) = hikari.UNDEFINED
) -> t.Callable[
[
t.Callable[
[ScreenT, miru.ViewContext, ScreenButton],
t.Awaitable[None],
]
],
DecoratedScreenItem[ScreenT, ScreenButton],
]
A decorator to transform a coroutine function into a Discord UI Button's callback.
This must be inside a subclass of Screen
.
PARAMETER | DESCRIPTION |
---|---|
label |
The button's label
TYPE:
|
custom_id |
The button's custom ID
TYPE:
|
style |
The style of the button
TYPE:
|
emoji |
The emoji shown on the button |
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[[ScreenT, miru.ViewContext, ScreenButton], Awaitable[None]]], DecoratedScreenItem[ScreenT, ScreenButton]]
|
The decorated callback coroutine function. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the decorated function is not a coroutine function. |
channel_select
#
channel_select(
*,
channel_types: t.Sequence[hikari.ChannelType] = (
hikari.ChannelType.GUILD_TEXT
),
custom_id: str | None = None,
placeholder: str | None = None,
min_values: int = 1,
max_values: int = 1,
disabled: bool = False,
row: int | None = None,
autodefer: (
bool | miru.AutodeferOptions | hikari.UndefinedType
) = hikari.UNDEFINED
) -> t.Callable[
[
t.Callable[
[
ScreenT,
miru.ViewContext,
ScreenChannelSelect,
],
t.Awaitable[None],
]
],
DecoratedScreenItem[ScreenT, ScreenChannelSelect],
]
A decorator to transform a function into a Discord UI ChannelSelectMenu's callback.
This must be inside a subclass of Screen
.
PARAMETER | DESCRIPTION |
---|---|
channel_types |
A sequence of channel types to filter the select menu by. Defaults to (hikari.ChannelType.GUILD_TEXT,).
TYPE:
|
custom_id |
The custom ID for the select menu. Defaults to None.
TYPE:
|
placeholder |
The placeholder text for the channel select menu. Defaults to None.
TYPE:
|
min_values |
The minimum number of values that can be selected. Defaults to 1.
TYPE:
|
max_values |
The maximum number of values that can be selected. Defaults to 1.
TYPE:
|
disabled |
Whether the channel select menu is disabled or not. Defaults to False.
TYPE:
|
row |
The row the select should be in, leave as None for auto-placement.
TYPE:
|
autodefer |
The autodefer options for the select menu. If left
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Callable[[Callable[[ScreenT, ScreenChannelSelect, ViewContextT], Awaitable[None]]], DecoratedScreenItem[ScreenT, ScreenChannelSelect, ViewContextT]]
|
The decorated function. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the decorated function is not a coroutine function. |
mentionable_select
#
mentionable_select(
*,
custom_id: str | None = None,
placeholder: str | None = None,
min_values: int = 1,
max_values: int = 1,
disabled: bool = False,
row: int | None = None,
autodefer: (
bool | miru.AutodeferOptions | hikari.UndefinedType
) = hikari.UNDEFINED
) -> t.Callable[
[
t.Callable[
[
ScreenT,
miru.ViewContext,
ScreenMentionableSelect,
],
t.Awaitable[None],
]
],
DecoratedScreenItem[ScreenT, ScreenMentionableSelect],
]
A decorator to transform a function into a Discord UI MentionableSelectMenu's callback.
This must be inside a subclass of Screen
.
PARAMETER | DESCRIPTION |
---|---|
custom_id |
The custom ID for the select menu
TYPE:
|
placeholder |
The placeholder text to display when no option is selected
TYPE:
|
min_values |
The minimum number of values that can be selected
TYPE:
|
max_values |
The maximum number of values that can be selected
TYPE:
|
disabled |
Whether the mentionable select menu is disabled
TYPE:
|
row |
The row the select should be in, leave as None for auto-placement.
TYPE:
|
autodefer |
The autodefer options for the select menu. If left
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Callable[[Callable[[ScreenT, ScreenMentionableSelect, ViewContextT], Awaitable[None]]], DecoratedScreenItem[ScreenT, ScreenMentionableSelect, ViewContextT]]
|
The decorated function. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the decorated function is not a coroutine function. |
role_select
#
role_select(
*,
custom_id: str | None = None,
placeholder: str | None = None,
min_values: int = 1,
max_values: int = 1,
disabled: bool = False,
row: int | None = None,
autodefer: (
bool | miru.AutodeferOptions | hikari.UndefinedType
) = hikari.UNDEFINED
) -> t.Callable[
[
t.Callable[
[ScreenT, miru.ViewContext, ScreenRoleSelect],
t.Awaitable[None],
]
],
DecoratedScreenItem[ScreenT, ScreenRoleSelect],
]
A decorator to transform a function into a Discord UI RoleSelectMenu's callback.
This must be inside a subclass of Screen
.
PARAMETER | DESCRIPTION |
---|---|
custom_id |
The custom ID for the select menu
TYPE:
|
placeholder |
The placeholder text to display when no roles are selected
TYPE:
|
min_values |
The minimum number of roles that can be selected
TYPE:
|
max_values |
The maximum number of roles that can be selected
TYPE:
|
disabled |
Whether the select menu is disabled or not
TYPE:
|
row |
The row number to place the select menu in
TYPE:
|
autodefer |
The autodefer options for the select menu. If left
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Callable[[Callable[[ScreenT, ScreenRoleSelect, ViewContextT], Awaitable[None]]], DecoratedScreenItem[ScreenT, ScreenRoleSelect, ViewContextT]]
|
The decorated function that serves as the callback for the select menu. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the decorated function is not a coroutine function. |
text_select
#
text_select(
*,
options: t.Sequence[
hikari.SelectMenuOption | miru.SelectOption
],
custom_id: str | None = None,
placeholder: str | None = None,
min_values: int = 1,
max_values: int = 1,
disabled: bool = False,
row: int | None = None,
autodefer: (
bool | miru.AutodeferOptions | hikari.UndefinedType
) = hikari.UNDEFINED
) -> t.Callable[
[
t.Callable[
[ScreenT, miru.ViewContext, ScreenTextSelect],
t.Awaitable[None],
]
],
DecoratedScreenItem[ScreenT, ScreenTextSelect],
]
A decorator to transform a function into a Discord UI TextSelectMenu's callback.
This must be inside a subclass of Screen
.
PARAMETER | DESCRIPTION |
---|---|
options |
The options to add to the select menu.
TYPE:
|
custom_id |
The custom ID for the select menu
TYPE:
|
placeholder |
The placeholder text to display when no options are selected
TYPE:
|
min_values |
The minimum number of options that can be selected
TYPE:
|
max_values |
The maximum number of options that can be selected
TYPE:
|
disabled |
Whether the select menu is disabled or not
TYPE:
|
row |
The row number to place the select menu in
TYPE:
|
autodefer |
The autodefer options for the select menu. If left
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Callable[[Callable[[ScreenT, ScreenTextSelect, ViewContextT], Awaitable[None]]], DecoratedScreenItem[ScreenT, ScreenTextSelect, ViewContextT]]
|
The decorated function that serves as the callback for the select menu. |
user_select
#
user_select(
*,
custom_id: str | None = None,
placeholder: str | None = None,
min_values: int = 1,
max_values: int = 1,
disabled: bool = False,
row: int | None = None,
autodefer: (
bool | miru.AutodeferOptions | hikari.UndefinedType
) = hikari.UNDEFINED
) -> t.Callable[
[
t.Callable[
[ScreenT, miru.ViewContext, ScreenUserSelect],
t.Awaitable[None],
]
],
DecoratedScreenItem[ScreenT, ScreenUserSelect],
]
A decorator to transform a function into a Discord UI UserSelectMenu's callback.
This must be inside a subclass of Screen
.
PARAMETER | DESCRIPTION |
---|---|
custom_id |
The custom ID for the select menu
TYPE:
|
placeholder |
The placeholder text to display when no users are selected
TYPE:
|
min_values |
The minimum number of users that can be selected
TYPE:
|
max_values |
The maximum number of users that can be selected
TYPE:
|
disabled |
Whether the select menu is disabled or not
TYPE:
|
row |
The row number to place the select menu in
TYPE:
|
autodefer |
The autodefer options for the select menu. If left
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Callable[[Callable[[ScreenT, ScreenUserSelect, ViewContextT], Awaitable[None]]], DecoratedScreenItem[ScreenT, ScreenUserSelect, ViewContextT]]
|
The decorated function that serves as the callback for the select menu. |