yuyo.components#
Higher level client for callback based component execution.
CallbackSig module-attribute
#
CallbackSig = collections.Callable[..., collections.Coroutine[typing.Any, typing.Any, None]]
Type hint of a component callback.
AbstractComponentExecutor #
Bases: ABC
Abstract interface of an object which handles the execution of a message component.
custom_ids abstractmethod
property
#
custom_ids: collections.Collection[str]
Collection of the custom IDs this executor is listening for.
execute abstractmethod
async
#
execute(ctx)
Execute this component.
Parameters:
- ctx (
Context
) –The context to execute this with.
Raises:
-
ExecutorClosed
–If the executor is closed.
ActionColumnExecutor #
Bases: AbstractComponentExecutor
Executor which handles columns of action rows.
This can be used to declare and handle the components on a message a couple of ways.
To send a column's components pass ActionColumnExecutor.rows as components
when calling the create message method (e.g. respond
/create_message
).
Examples:
Sub-components can be added to an instance of the column executor using chainable methods on it:
async def callback_1(ctx: components.Context) -> None:
await ctx.respond("meow")
components = (
components.ActionColumnExecutor()
.add_interactive_button(hikari.ButtonStyle.PRIMARY, chainable, label="Button 1")
.add_link_button("https://example.com", label="Button 2",)
)
Alternatively, subclasses of ActionColumnExecutor can act as a template where "static" fields are included on all instances and subclasses of that class:
Note
Since decorators are executed from the bottom upwards fields added through decorator calls will follow the same order.
async def callback_1(ctx: components.Context) -> None:
await ctx.respond("meow")
async def callback_2(ctx: components.Context) -> None:
await ctx.respond("meow")
@components.with_static_select_menu(callback_1, hikari.ComponentType.USER_SELECT_MENU, max_values=5)
class CustomColumn(components.ActionColumnExecutor):
__slots__ = ("special_string",) # ActionColumnExecutor supports slotting.
# The init can be overridden to store extra data on the column object when subclassing.
def __init__(self, special_string: str, timeout: typing.Optional[datetime.timedelta] = None):
super().__init__(timeout=timeout)
self.special_string = special_string
(
CustomColumn.add_static_text_menu(callback_2, min_values=0, max_values=3)
# The following calls are all adding options to the added
# text select menu.
.add_option("Option 1", "value 1")
.add_option("Option 2", "value 2")
.add_option("Option 3", "value 3")
)
There's also class descriptors which can be used to declare static components. The following descriptors work by decorating their component's callback:
link_button returns a descriptor without decorating any callback.
class CustomColumn(components.ActionColumnExecutor):
@components.as_interactive_button(ButtonStyle.PRIMARY, label="label")
async def left_button(self, ctx: components.Context) -> None:
...
link_button = components.link_button(url="https://example.com", label="Go to page")
@components.as_interactive_button(ButtonStyle.SECONDARY, label="meow")
async def right_button(self, ctx: components.Context) -> None:
...
@components.as_channel_menu(channel_types=[hikari.TextableChannel], custom_id="eep")
async def text_select_menu(self, ctx: components.Context) -> None:
...
rows property
#
rows: collections.Sequence[hikari.api.MessageActionRowBuilder]
The rows in this column.
__init__ #
__init__(*, authors=None, ephemeral_default=False, id_metadata=None)
Initialise an action column executor.
Parameters:
- authors (
typing.Optional[abc.Iterable[hikari.SnowflakeishOr[hikari.User]]]
, default:None
) –Users who are allowed to use the components this represents.
If no users are provided then the components will be public (meaning that anybody can use it).
- ephemeral_default (
bool
, default:False
) –Whether or not the responses made on contexts spawned from this executor should default to ephemeral (meaning only the author can see them) unless
flags
is specified on the response method. - id_metadata (
typing.Optional[abc.Mapping[str, str]]
, default:None
) –Mapping of metadata to append to the custom IDs in this column.
The keys in this can either be the match part of component custom IDs or the names of the component's callback when it was added using one of the
as_
class descriptors.
add_builder #
add_builder(builder)
Add a raw component builder to this action column.
This is mostly for adding components where the custom ID is already registered as a separate constant executor.
Parameters:
- builder (
ComponentBuilder
) –The component builder to add to the column.
add_channel_menu #
add_channel_menu(callback, /, *, custom_id=None, channel_types=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a channel select menu to this action column.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- channel_types (
typing.Optional[abc.Sequence[typing.Union[ChannelType, type[hikari.PartialChannel]]]]
, default:None
) –Sequence of the types of channels this select menu should show as options.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
Self
–The action column to enable chained calls.
add_interactive_button #
add_interactive_button(style, callback, /, *, custom_id=None, emoji=hikari.UNDEFINED, label=hikari.UNDEFINED, is_disabled=False)
Add an interactive button to this action column.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- style (
InteractiveButtonTypesT
) –The button's style.
- callback (
CallbackSig
) –The button's execution callback.
- custom_id (
typing.Optional[str]
, default:None
) –The button's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:UNDEFINED
) –The button's emoji.
- label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –The button's label.
- is_disabled (
bool
, default:False
) –Whether the button should be marked as disabled.
Returns:
-
Self
–The action column to enable chained calls.
add_link_button #
add_link_button(url, /, *, emoji=hikari.UNDEFINED, label=hikari.UNDEFINED, is_disabled=False)
Add a link button to this action column.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- url (
str
) –The button's url.
- emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:UNDEFINED
) –The button's emoji.
- label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –The button's label.
- is_disabled (
bool
, default:False
) –Whether the button should be marked as disabled.
Returns:
-
Self
–The action column to enable chained calls.
add_mentionable_menu #
add_mentionable_menu(callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a mentionable select menu to this action column.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
Self
–The action column to enable chained calls.
add_role_menu #
add_role_menu(callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a role select menu to this action column.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
Self
–The action column to enable chained calls.
add_select_menu #
add_select_menu(type_, callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a select menu to this action column.
The following methods should be used instead:
add_static_builder classmethod
#
add_static_builder(builder)
Add a raw component builder to all subclasses and instances of this column.
This is mostly for adding components where the custom ID is already registered as a separate constant executor.
Parameters:
- builder (
ComponentBuilder
) –The component builder to add to the column class.
add_static_channel_menu classmethod
#
add_static_channel_menu(callback, /, *, custom_id=None, channel_types=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a channel select menu to all subclasses and instances of this action column class.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- channel_types (
typing.Optional[abc.Sequence[typing.Union[ChannelType, type[hikari.PartialChannel]]]]
, default:None
) –Sequence of the types of channels this select menu should show as options.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
type[Self]
–The action column class to enable chained calls.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
add_static_interactive_button classmethod
#
add_static_interactive_button(style, callback, /, *, custom_id=None, emoji=hikari.UNDEFINED, label=hikari.UNDEFINED, is_disabled=False)
Add an interactive button to all subclasses and instances of this action column class.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- style (
InteractiveButtonTypesT
) –The button's style.
- callback (
CallbackSig
) –The button's execution callback.
- custom_id (
typing.Optional[str]
, default:None
) –The button's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:UNDEFINED
) –The button's emoji.
- label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –The button's label.
- is_disabled (
bool
, default:False
) –Whether the button should be marked as disabled.
Returns:
-
type[Self]
–The action column class to enable chained calls.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
add_static_link_button classmethod
#
add_static_link_button(url, /, *, emoji=hikari.UNDEFINED, label=hikari.UNDEFINED, is_disabled=False)
Add a link button to all subclasses and instances of this action column class.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- url (
str
) –The button's url.
- emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:UNDEFINED
) –The button's emoji.
- label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –The button's label.
- is_disabled (
bool
, default:False
) –Whether the button should be marked as disabled.
Returns:
-
type[Self]
–The action column class to enable chained calls.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
add_static_mentionable_menu classmethod
#
add_static_mentionable_menu(callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a mentionable select menu to all subclasses and instances of this action column class.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
type[Self]
–The action column class to enable chained calls.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
add_static_role_menu classmethod
#
add_static_role_menu(callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a role select menu to all subclasses and instances of this action column class.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
type[Self]
–The action column class to enable chained calls.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
add_static_select_menu classmethod
#
add_static_select_menu(type_, callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a select menu to all subclasses and instances of this action column class.
The following class methods should be used instead:
add_static_text_menu classmethod
#
add_static_text_menu(callback, /, *, custom_id=None, options=(), placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a text select menu to all subclasses and instances of this action column class.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - options (
abc.Sequence[hikari.api.SelectOptionBuilder]
, default:()
) –The text select's options.
These can also be added by calling TextSelectMenuBuilder.add_option.
- placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
TextSelectMenuBuilder
–Builder for the added text select menu.
TextSelectMenuBuilder.add_option should be used to add options to this select menu.
And the parent action column can be accessed by calling TextSelectMenuBuilder.parent.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
add_static_user_menu classmethod
#
add_static_user_menu(callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a user select menu to all subclasses and instances of this action column class.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
type[Self]
–The action column class to enable chained calls.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
add_text_menu #
add_text_menu(callback, /, *, custom_id=None, options=(), placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a text select menu to this action column.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - options (
abc.Sequence[hikari.api.SelectOptionBuilder]
, default:()
) –The text select's options.
These can also be added by calling TextSelectMenuBuilder.add_option.
- placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
TextSelectMenuBuilder
–Builder for the added text select menu.
TextSelectMenuBuilder.add_option should be used to add options to this select menu.
And the parent action column can be accessed by calling TextSelectMenuBuilder.parent.
add_user_menu #
add_user_menu(callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a user select menu to this action column.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
Self
–The action column to enable chained calls.
with_channel_menu #
with_channel_menu(callback=None, /, *, custom_id=None, channel_types=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a channel select menu to this action column through a decorator call.
Parameters:
- channel_types (
typing.Optional[abc.Sequence[typing.Union[ChannelType, type[hikari.PartialChannel]]]]
, default:None
) –Sequence of the types of channels this select menu should show as options.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
with_interactive_button #
with_interactive_button(style, /, *, custom_id=None, emoji=hikari.UNDEFINED, label=hikari.UNDEFINED, is_disabled=False)
Add an interactive button to this action column through a decorator call.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- style (
InteractiveButtonTypesT
) –The button's style.
- custom_id (
typing.Optional[str]
, default:None
) –The button's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:UNDEFINED
) –The button's emoji.
- label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –The button's label.
- is_disabled (
bool
, default:False
) –Whether the button should be marked as disabled.
with_mentionable_menu #
with_mentionable_menu(callback=None, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a mentionable select menu to this action column through a decorator call.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
with_role_menu #
with_role_menu(callback=None, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a role select menu to this action column through a decorator call.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
with_static_channel_menu classmethod
#
with_static_channel_menu(callback=None, /, *, custom_id=None, channel_types=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a channel select menu to this action column class through a decorator call.
Parameters:
- channel_types (
typing.Optional[abc.Sequence[typing.Union[ChannelType, type[hikari.PartialChannel]]]]
, default:None
) –Sequence of the types of channels this select menu should show as options.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
with_static_interactive_button classmethod
#
with_static_interactive_button(style, /, *, custom_id=None, emoji=hikari.UNDEFINED, label=hikari.UNDEFINED, is_disabled=False)
Add a static interactive button to this action column class through a decorator call.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- style (
InteractiveButtonTypesT
) –The button's style.
- custom_id (
typing.Optional[str]
, default:None
) –The button's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:UNDEFINED
) –The button's emoji.
- label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –The button's label.
- is_disabled (
bool
, default:False
) –Whether the button should be marked as disabled.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
with_static_mentionable_menu classmethod
#
with_static_mentionable_menu(callback=None, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a static mentionable select menu to this action column class through a decorator call.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
with_static_role_menu classmethod
#
with_static_role_menu(callback=None, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a static role select menu to this action column class through a decorator call.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
with_static_text_menu classmethod
#
with_static_text_menu(callback=None, /, *, custom_id=None, options=(), placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a text select menu to this action column class through a decorator call.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - options (
abc.Sequence[hikari.api.SelectOptionBuilder]
, default:()
) –The text select's options.
These can also be added using [yuyo.components.with_option].
- placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
with_static_user_menu classmethod
#
with_static_user_menu(callback=None, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a static user select menu to this action column class through a decorator call.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
with_text_menu #
with_text_menu(callback=None, /, *, custom_id=None, options=(), placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a text select menu to this action column through a decorator callback.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - options (
abc.Sequence[hikari.api.SelectOptionBuilder]
, default:()
) –The text select's options.
These can also be added using components.with_option.
- placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
with_user_menu #
with_user_menu(callback=None, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a user select menu to this action column through a decorator call.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
BaseContext #
Bases: ABC
, typing.Generic[_InteractionT]
Base class for components contexts.
cache abstractmethod
property
#
cache: typing.Optional[hikari.api.Cache]
Hikari cache instance this context's client was initialised with.
channel_id property
#
channel_id: hikari.Snowflake
ID of the channel this interaction was triggered in.
events abstractmethod
property
#
events: typing.Optional[hikari.api.EventManager]
Object of the event manager this context's client was initialised with.
expires_at property
#
expires_at: datetime.datetime
When this context expires.
After this time is reached, the message/response methods on this context will always raise hikari.NotFoundError.
has_been_deferred property
#
has_been_deferred: bool
Whether this context's initial response has been deferred.
This will be true if BaseContext.defer has been called.
has_responded property
#
has_responded: bool
Whether an initial response has been made to this context yet.
It's worth noting that a context must be either responded to or deferred within 3 seconds from it being received otherwise it'll be marked as failed.
This will be true if either BaseContext.respond, BaseContext.create_initial_response or BaseContext.edit_initial_response (after a deferral) has been called.
rest abstractmethod
property
#
rest: typing.Optional[hikari.api.RESTClient]
Object of the Hikari REST client this context's client was initialised with.
server abstractmethod
property
#
server: typing.Optional[hikari.api.InteractionServer]
Object of the Hikari interaction server provided for this context's client.
shard property
#
shard: typing.Optional[hikari.api.GatewayShard]
Shard that triggered the interaction.
Note
This will be None if BaseContext.shards is also None.
shards abstractmethod
property
#
shards: typing.Optional[hikari.ShardAware]
Object of the Hikari shard manager this context's client was initialised with.
voice abstractmethod
property
#
voice: typing.Optional[hikari.api.VoiceComponent]
Object of the Hikari voice component this context's client was initialised with.
create_followup async
#
create_followup(content=hikari.UNDEFINED, *, delete_after=None, ephemeral=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED, tts=hikari.UNDEFINED, flags=hikari.UNDEFINED)
Create a followup response for this context.
Warning
Calling this on a context which hasn't had an initial response yet will lead to a hikari.NotFoundError being raised.
Parameters:
- content (
hikari.UndefinedOr[typing.Any]
, default:UNDEFINED
) –If provided, the message content to send.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead be treated as an embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. - delete_after (
typing.Union[timedelta, float, int, None]
, default:None
) –If provided, the seconds after which the response message should be deleted.
Interaction responses can only be deleted within 15 minutes of the interaction being received.
- ephemeral (
typing.Optional[bool]
, default:None
) –Whether the deferred response should be ephemeral. Passing True here is a shorthand for including
1 << 64
in the passed flags. - attachment (
hikari.UndefinedOr[hikari.Resourceish]
, default:UNDEFINED
) –If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.
- attachments (
hikari.UndefinedOr[abc.Sequence[hikari.Resourceish]]
, default:UNDEFINED
) –If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
- component (
hikari.UndefinedOr[hikari.api.ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to include in this message.
- components (
hikari.UndefinedOr[abc.Sequence[hikari.api.ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects to include in this message.
- embed (
hikari.UndefinedOr[hikari.Embed]
, default:UNDEFINED
) –If provided, the message embed.
- embeds (
hikari.UndefinedOr[abc.Sequence[hikari.Embed]]
, default:UNDEFINED
) –If provided, the message embeds.
- mentions_everyone (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
- role_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
- tts (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message will be sent as a TTS message.
- flags (
typing.Union[UndefinedType, int, MessageFlag]
, default:UNDEFINED
) –The flags to set for this response.
As of writing this can only flag which can be provided is EPHEMERAL, other flags are just ignored.
Returns:
-
Message
–The created message object.
Raises:
-
NotFoundError
–If the current interaction is not found or it hasn't had an initial response yet.
-
BadRequestError
–This can be raised if the file is too large; if the embed exceeds the defined limits; if the message content is specified only and empty or greater than
2000
characters; if neither content, file or embeds are specified. If any invalid snowflake IDs are passed; a snowflake may be invalid due to it being outside of the range of a 64 bit integer. -
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
or `user_mentions.If the interaction will have expired before
delete_after
is reached.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed.
create_initial_response async
#
create_initial_response(content=hikari.UNDEFINED, *, response_type=hikari.ResponseType.MESSAGE_CREATE, delete_after=None, ephemeral=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED, flags=hikari.UNDEFINED, tts=hikari.UNDEFINED)
Create the initial response for this context.
Warning
Calling this on a context which already has an initial response will result in this raising a hikari.NotFoundError. This includes if the REST interaction server has already responded to the request and deferrals.
Parameters:
- content (
hikari.UndefinedOr[typing.Any]
, default:UNDEFINED
) –If provided, the message content to respond with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead be treated as an embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. - response_type (
MessageResponseTypesT
, default:MESSAGE_CREATE
) –The type of message response to give.
- delete_after (
typing.Union[timedelta, float, int, None]
, default:None
) –If provided, the seconds after which the response message should be deleted.
Interaction responses can only be deleted within 15 minutes of the interaction being received.
- ephemeral (
typing.Optional[bool]
, default:None
) –Whether the deferred response should be ephemeral.
Passing True here is a shorthand for including
1 << 64
in the passed flags. - attachment (
hikari.UndefinedOr[hikari.Resourceish]
, default:UNDEFINED
) –If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.
- attachments (
hikari.UndefinedOr[abc.Sequence[hikari.Resourceish]]
, default:UNDEFINED
) –If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
- component (
hikari.UndefinedOr[hikari.api.ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to include in this message.
- components (
hikari.UndefinedOr[abc.Sequence[hikari.api.ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects to include in this message.
- embed (
hikari.UndefinedOr[hikari.Embed]
, default:UNDEFINED
) –If provided, the message embed.
- embeds (
hikari.UndefinedOr[abc.Sequence[hikari.Embed]]
, default:UNDEFINED
) –If provided, the message embeds.
- flags (
typing.Union[int, MessageFlag, UndefinedType]
, default:UNDEFINED
) –If provided, the message flags this response should have.
As of writing the only message flag which can be set here is MessageFlag.EPHEMERAL.
- tts (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system.
- mentions_everyone (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
- role_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If the interaction will have expired before
delete_after
is reached.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; invalid image URLs in embeds.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
NotFoundError
–If the interaction is not found or if the interaction's initial response has already been created.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
defer async
#
defer(*, defer_type=hikari.ResponseType.DEFERRED_MESSAGE_CREATE, ephemeral=None, flags=hikari.UNDEFINED)
Defer the initial response for this context.
Note
The ephemeral state of the first response is decided by whether the deferral is ephemeral.
Parameters:
- defer_type (
DeferredResponseTypesT
, default:DEFERRED_MESSAGE_CREATE
) –The type of deferral this should be.
This may any of the following:
- ResponseType.DEFERRED_MESSAGE_CREATE to indicate that the following up call to BaseContext.edit_initial_response or BaseContext.respond should create a new message.
- ResponseType.DEFERRED_MESSAGE_UPDATE to indicate that the following call to the aforementioned methods should update the existing message.
- ephemeral (
typing.Optional[bool]
, default:None
) –Whether the deferred response should be ephemeral.
Passing True here is a shorthand for including
1 << 64
in the passed flags. - flags (
typing.Union[UndefinedType, int, MessageFlag]
, default:UNDEFINED
) –The flags to use for the initial response.
delete_initial_response async
#
delete_initial_response()
Delete the initial response after invoking this context.
Raises:
-
(LookupError, NotFoundError)
–The last context has no initial response.
delete_last_response async
#
delete_last_response()
Delete the last response after invoking this context.
Raises:
-
(LookupError, NotFoundError)
–The last context has no responses.
edit_initial_response async
#
edit_initial_response(content=hikari.UNDEFINED, *, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Edit the initial response for this context.
Parameters:
- content (
hikari.UndefinedOr[typing.Any]
, default:UNDEFINED
) –If provided, the message content to edit the initial response with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. - delete_after (
typing.Union[timedelta, float, int, None]
, default:None
) –If provided, the seconds after which the response message should be deleted.
Interaction responses can only be deleted within 15 minutes of the interaction being received.
- attachment (
hikari.UndefinedNoneOr[hikari.Resourceish]
, default:UNDEFINED
) –A singular attachment to edit the initial response with.
- attachments (
hikari.UndefinedNoneOr[abc.Sequence[hikari.Resourceish]]
, default:UNDEFINED
) –A sequence of attachments to edit the initial response with.
- component (
hikari.UndefinedNoneOr[hikari.api.ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to set for this message. This component will replace any previously set components and passing None will remove all components.
- components (
hikari.UndefinedNoneOr[abc.Sequence[hikari.api.ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing None or an empty sequence will remove all components.
- embed (
hikari.UndefinedNoneOr[hikari.Embed]
, default:UNDEFINED
) –An embed to replace the initial response with.
- embeds (
hikari.UndefinedNoneOr[abc.Sequence[hikari.Embed]]
, default:UNDEFINED
) –A sequence of embeds to replace the initial response with.
- mentions_everyone (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
- role_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message
–The message that has been edited.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the interaction was received.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
edit_last_response async
#
edit_last_response(content=hikari.UNDEFINED, *, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Edit the last response for this context.
Parameters:
- content (
hikari.UndefinedOr[typing.Any]
, default:UNDEFINED
) –If provided, the content to edit the last response with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. - delete_after (
typing.Union[timedelta, float, int, None]
, default:None
) –If provided, the seconds after which the response message should be deleted.
Interaction responses can only be deleted within 15 minutes of the interaction being received.
- attachment (
hikari.UndefinedNoneOr[hikari.Resourceish]
, default:UNDEFINED
) –A singular attachment to edit the last response with.
- attachments (
hikari.UndefinedNoneOr[abc.Sequence[hikari.Resourceish]]
, default:UNDEFINED
) –A sequence of attachments to edit the last response with.
- component (
hikari.UndefinedNoneOr[hikari.api.ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to set for this message. This component will replace any previously set components and passing None will remove all components.
- components (
hikari.UndefinedNoneOr[abc.Sequence[hikari.api.ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing None or an empty sequence will remove all components.
- embed (
hikari.UndefinedNoneOr[hikari.Embed]
, default:UNDEFINED
) –An embed to replace the last response with.
- embeds (
hikari.UndefinedNoneOr[abc.Sequence[hikari.Embed]]
, default:UNDEFINED
) –A sequence of embeds to replace the last response with.
- mentions_everyone (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
- role_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message
–The message that has been edited.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the slash interaction was received.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
fetch_initial_response async
#
fetch_initial_response()
Fetch the initial response for this context.
Returns:
-
Message
–The initial response's message object.
Raises:
-
(LookupError, NotFoundError)
–The response was not found.
fetch_last_response async
#
fetch_last_response()
Fetch the last response for this context.
Returns:
-
Message
–The most response response's message object.
Raises:
-
(LookupError, NotFoundError)
–The response was not found.
respond async
#
respond(content=hikari.UNDEFINED, *, ensure_result=False, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Respond to this context.
Parameters:
- content (
hikari.UndefinedOr[typing.Any]
, default:UNDEFINED
) –If provided, the message content to respond with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead be treated as an embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. - ensure_result (
bool
, default:False
) –Ensure that this call will always return a message object.
If True then this will always return hikari.Message, otherwise this will return
hikari.Message | None
.It's worth noting that this may lead to an extre request being made under certain scenarios.
- delete_after (
typing.Union[timedelta, float, int, None]
, default:None
) –If provided, the seconds after which the response message should be deleted.
Interaction responses can only be deleted within 15 minutes of the interaction being received.
- attachment (
hikari.UndefinedOr[hikari.Resourceish]
, default:UNDEFINED
) –If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.
- attachments (
hikari.UndefinedOr[abc.Sequence[hikari.Resourceish]]
, default:UNDEFINED
) –If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
- component (
hikari.UndefinedOr[hikari.api.ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to include in this response.
- components (
hikari.UndefinedOr[abc.Sequence[hikari.api.ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects to include in this response.
- embed (
hikari.UndefinedOr[hikari.Embed]
, default:UNDEFINED
) –An embed to respond with.
- embeds (
hikari.UndefinedOr[abc.Sequence[hikari.Embed]]
, default:UNDEFINED
) –A sequence of embeds to respond with.
- mentions_everyone (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
- role_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message | None
–
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the interaction was received.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
ComponentClient #
Client used to handle component executors within a REST or gateway flow.
alluka property
#
alluka: alluka_.abc.Client
The Alluka client being used for callback dependency injection.
cache property
#
cache: typing.Optional[hikari.api.Cache]
Hikari cache instance this client was initialised with.
events property
#
events: typing.Optional[hikari.api.EventManager]
Object of the event manager this client was initialised with.
rest property
#
rest: typing.Optional[hikari.api.RESTClient]
Object of the Hikari REST client this client was initialised with.
server property
#
server: typing.Optional[hikari.api.InteractionServer]
Object of the Hikari interaction server provided for this client.
shards property
#
shards: typing.Optional[hikari.ShardAware]
Object of the Hikari shard manager this client was initialised with.
voice property
#
voice: typing.Optional[hikari.api.VoiceComponent]
Object of the Hikari voice component this client was initialised with.
__init__ #
__init__(*, alluka=None, cache=None, event_manager=None, event_managed=None, rest=None, server=None, shards=None, voice=None)
Initialise a component client.
This sets ComponentClient as a type dependency when alluka
isn't passed.
Note
For an easier way to initialise the client from a bot see ComponentClient.from_gateway_bot, ComponentClient.from_rest_bot, and ComponentClient.from_tanjun.
Parameters:
- alluka (
typing.Optional[alluka.abc.Client]
, default:None
) –The Alluka client to use for callback dependency injection in this client.
If not provided then this will initialise its own Alluka client.
- event_manager (
typing.Optional[hikari.api.EventManager]
, default:None
) –The event manager this client should listen to dispatched component interactions from if applicable.
- event_managed (
typing.Optional[bool]
, default:None
) –Whether this client should be automatically opened and closed based on the lifetime events dispatched by
event_manager
.Defaults to True if an event manager is passed.
- server (
typing.Optional[hikari.api.InteractionServer]
, default:None
) –The server this client should listen to component interactions from if applicable.
Raises:
deregister_executor #
deregister_executor(executor)
Remove a component executor by its custom IDs.
Parameters:
- executor (
AbstractComponentExecutor
) –The executor to remove.
Returns:
-
Self
–The component client to allow chaining.
Raises:
-
KeyError
–If the executor isn't registered.
deregister_message #
deregister_message(message)
from_gateway_bot classmethod
#
from_gateway_bot(bot, /, *, alluka=None, event_managed=True)
Build a component client from a Gateway Bot.
This sets ComponentClient as a type dependency when alluka
isn't passed.
Parameters:
- bot (
_GatewayBotProto
) –The Gateway bot this component client should be bound to.
- alluka (
typing.Optional[alluka.abc.Client]
, default:None
) –The Alluka client to use for callback dependency injection in this client.
If not provided then this will initialise its own Alluka client.
- event_managed (
bool
, default:True
) –Whether the component client should be automatically opened and closed based on the lifetime events dispatched by
bot
.
Returns:
-
ComponentClient
–The initialised component client.
from_rest_bot classmethod
#
from_rest_bot(bot, /, *, alluka=None, bot_managed=False)
Build a component client from a REST Bot.
This sets ComponentClient as a type dependency when alluka
isn't passed.
Parameters:
- bot (
RESTBotAware
) –The REST bot this component client should be bound to.
- alluka (
typing.Optional[alluka.abc.Client]
, default:None
) –The Alluka client to use for callback dependency injection in this client.
If not provided then this will initialise its own Alluka client.
- bot_managed (
bool
, default:False
) –Whether the component client should be automatically opened and closed based on the Bot's startup and shutdown callbacks.
Returns:
-
ComponentClient
–The initialised component client.
from_tanjun classmethod
#
from_tanjun(tanjun_client, /, *, tanjun_managed=True)
Build a component client from a Tanjun client.
This will use the Tanjun client's alluka client and registers ComponentClient as a type dependency on Tanjun.
Parameters:
- tanjun_client (
Client
) –The Tanjun client this component client should be bound to.
- tanjun_managed (
bool
, default:True
) –Whether the component client should be automatically opened and closed based on the Tanjun client's lifetime client callback.
Returns:
-
ComponentClient
–The initialised component client.
get_executor #
get_executor(custom_id)
Get the component executor registered for a custom ID.
Note
For message scoped executors use get_executor_for_message. as they will not be returned here.
Parameters:
- custom_id (
str
) –The custom ID to get the executor for.
Returns:
-
AbstractComponentExecutor | None
–The executor set for the custom ID or None if none is set.
get_executor_for_message #
get_executor_for_message(message)
Get the component executor registered for a message.
Parameters:
Returns:
-
AbstractComponentExecutor | None
–The executor set for the message or None if none is set.
on_gateway_event async
#
on_gateway_event(event)
Process an interaction create gateway event.
Parameters:
- event (
InteractionCreateEvent
) –The interaction create gateway event to process.
on_rest_request async
#
on_rest_request(interaction)
Process a component interaction REST request.
Parameters:
- interaction (
ComponentInteraction
) –The interaction to process.
Returns:
-
ResponseT
–The REST response.
register_executor #
register_executor(executor, /, *, message=None, timeout=_internal.NO_DEFAULT)
Add an executor to this client.
Parameters:
- executor (
AbstractComponentExecutor
) –The executor to register.
- message (
typing.Optional[hikari.SnowflakeishOr[hikari.Message]]
, default:None
) –The message to register this executor for.
If this is left as None then this executor will be registered globally for its custom IDs.
- timeout (
typing.Union[AbstractTimeout, None, NoDefault]
, default:NO_DEFAULT
) –The executor's timeout.
This defaults to a 30 second sliding timeout.
Returns:
-
Self
–The component client to allow chaining.
Raises:
-
ValueError
–If
message
is already registered when it's passed.If any of the executor's custom IDs are already registered when
message
wasn't passed.
ComponentContext #
Bases: BaseContext[hikari.ComponentInteraction]
The context used for message component triggers.
cache property
#
cache: typing.Optional[hikari.api.Cache]
Hikari cache instance this context's client was initialised with.
channel_id property
#
channel_id: hikari.Snowflake
ID of the channel this interaction was triggered in.
events property
#
events: typing.Optional[hikari.api.EventManager]
Object of the event manager this context's client was initialised with.
expires_at property
#
expires_at: datetime.datetime
When this context expires.
After this time is reached, the message/response methods on this context will always raise hikari.NotFoundError.
has_been_deferred property
#
has_been_deferred: bool
Whether this context's initial response has been deferred.
This will be true if BaseContext.defer has been called.
has_responded property
#
has_responded: bool
Whether an initial response has been made to this context yet.
It's worth noting that a context must be either responded to or deferred within 3 seconds from it being received otherwise it'll be marked as failed.
This will be true if either BaseContext.respond, BaseContext.create_initial_response or BaseContext.edit_initial_response (after a deferral) has been called.
rest property
#
rest: typing.Optional[hikari.api.RESTClient]
Object of the Hikari REST client this context's client was initialised with.
selected_channels property
#
selected_channels: collections.Mapping[hikari.Snowflake, hikari.InteractionChannel]
Sequence of the users passed for a channel select menu.
selected_members property
#
selected_members: collections.Mapping[hikari.Snowflake, hikari.InteractionMember]
Sequence of the members passed for a user select menu.
This will also include some of the values for a mentionable select menu.
selected_roles property
#
selected_roles: collections.Mapping[hikari.Snowflake, hikari.Role]
Sequence of the users passed for a role select menu.
This will also include some of the values for a mentionable select menu.
selected_texts property
#
selected_texts: collections.Sequence[str]
Sequence of the values passed for a text select menu.
selected_users property
#
selected_users: collections.Mapping[hikari.Snowflake, hikari.User]
Sequence of the users passed for a user select menu.
This will also include some of the values for a mentionable select menu.
ComponentContext.selected_members has the full member objects.
server property
#
server: typing.Optional[hikari.api.InteractionServer]
Object of the Hikari interaction server provided for this context's client.
shard property
#
shard: typing.Optional[hikari.api.GatewayShard]
Shard that triggered the interaction.
Note
This will be None if BaseContext.shards is also None.
shards property
#
shards: typing.Optional[hikari.ShardAware]
Object of the Hikari shard manager this context's client was initialised with.
voice property
#
voice: typing.Optional[hikari.api.VoiceComponent]
Object of the Hikari voice component this context's client was initialised with.
create_followup async
#
create_followup(content=hikari.UNDEFINED, *, delete_after=None, ephemeral=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED, tts=hikari.UNDEFINED, flags=hikari.UNDEFINED)
Create a followup response for this context.
Warning
Calling this on a context which hasn't had an initial response yet will lead to a hikari.NotFoundError being raised.
Parameters:
- content (
hikari.UndefinedOr[typing.Any]
, default:UNDEFINED
) –If provided, the message content to send.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead be treated as an embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. - delete_after (
typing.Union[timedelta, float, int, None]
, default:None
) –If provided, the seconds after which the response message should be deleted.
Interaction responses can only be deleted within 15 minutes of the interaction being received.
- ephemeral (
typing.Optional[bool]
, default:None
) –Whether the deferred response should be ephemeral. Passing True here is a shorthand for including
1 << 64
in the passed flags. - attachment (
hikari.UndefinedOr[hikari.Resourceish]
, default:UNDEFINED
) –If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.
- attachments (
hikari.UndefinedOr[abc.Sequence[hikari.Resourceish]]
, default:UNDEFINED
) –If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
- component (
hikari.UndefinedOr[hikari.api.ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to include in this message.
- components (
hikari.UndefinedOr[abc.Sequence[hikari.api.ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects to include in this message.
- embed (
hikari.UndefinedOr[hikari.Embed]
, default:UNDEFINED
) –If provided, the message embed.
- embeds (
hikari.UndefinedOr[abc.Sequence[hikari.Embed]]
, default:UNDEFINED
) –If provided, the message embeds.
- mentions_everyone (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
- role_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
- tts (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message will be sent as a TTS message.
- flags (
typing.Union[UndefinedType, int, MessageFlag]
, default:UNDEFINED
) –The flags to set for this response.
As of writing this can only flag which can be provided is EPHEMERAL, other flags are just ignored.
Returns:
-
Message
–The created message object.
Raises:
-
NotFoundError
–If the current interaction is not found or it hasn't had an initial response yet.
-
BadRequestError
–This can be raised if the file is too large; if the embed exceeds the defined limits; if the message content is specified only and empty or greater than
2000
characters; if neither content, file or embeds are specified. If any invalid snowflake IDs are passed; a snowflake may be invalid due to it being outside of the range of a 64 bit integer. -
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
or `user_mentions.If the interaction will have expired before
delete_after
is reached.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed.
create_initial_response async
#
create_initial_response(content=hikari.UNDEFINED, *, response_type=hikari.ResponseType.MESSAGE_CREATE, delete_after=None, ephemeral=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED, flags=hikari.UNDEFINED, tts=hikari.UNDEFINED)
Create the initial response for this context.
Warning
Calling this on a context which already has an initial response will result in this raising a hikari.NotFoundError. This includes if the REST interaction server has already responded to the request and deferrals.
Parameters:
- content (
hikari.UndefinedOr[typing.Any]
, default:UNDEFINED
) –If provided, the message content to respond with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead be treated as an embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. - response_type (
MessageResponseTypesT
, default:MESSAGE_CREATE
) –The type of message response to give.
- delete_after (
typing.Union[timedelta, float, int, None]
, default:None
) –If provided, the seconds after which the response message should be deleted.
Interaction responses can only be deleted within 15 minutes of the interaction being received.
- ephemeral (
typing.Optional[bool]
, default:None
) –Whether the deferred response should be ephemeral.
Passing True here is a shorthand for including
1 << 64
in the passed flags. - attachment (
hikari.UndefinedOr[hikari.Resourceish]
, default:UNDEFINED
) –If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.
- attachments (
hikari.UndefinedOr[abc.Sequence[hikari.Resourceish]]
, default:UNDEFINED
) –If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
- component (
hikari.UndefinedOr[hikari.api.ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to include in this message.
- components (
hikari.UndefinedOr[abc.Sequence[hikari.api.ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects to include in this message.
- embed (
hikari.UndefinedOr[hikari.Embed]
, default:UNDEFINED
) –If provided, the message embed.
- embeds (
hikari.UndefinedOr[abc.Sequence[hikari.Embed]]
, default:UNDEFINED
) –If provided, the message embeds.
- flags (
typing.Union[int, MessageFlag, UndefinedType]
, default:UNDEFINED
) –If provided, the message flags this response should have.
As of writing the only message flag which can be set here is MessageFlag.EPHEMERAL.
- tts (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system.
- mentions_everyone (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
- role_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If the interaction will have expired before
delete_after
is reached.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; invalid image URLs in embeds.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
NotFoundError
–If the interaction is not found or if the interaction's initial response has already been created.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
create_modal_response async
#
create_modal_response(title, custom_id, /, *, component=hikari.UNDEFINED, components=hikari.UNDEFINED)
Send a modal as the initial response for this context.
Warning
This must be called as the first response to a context before any deferring.
Parameters:
- title (
str
) –The title that will show up in the modal.
- custom_id (
str
) –Developer set custom ID used for identifying interactions with this modal.
Yuyo's Component client will only match against
custom_id.split(":", 1)[0]
, allowing metadata to be put after":"
. - component (
hikari.UndefinedOr[hikari.api.ComponentBuilder]
, default:UNDEFINED
) –A component builder to send in this modal.
- components (
hikari.UndefinedOr[abc.Sequence[hikari.api.ComponentBuilder]]
, default:UNDEFINED
) –A sequence of component builders to send in this modal.
Raises:
-
ValueError
–If both
component
andcomponents
are specified or if none are specified. -
BadRequestError
–When the requests' data is outside Discord's accept ranges/validation.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
NotFoundError
–If the interaction is not found or if the interaction's initial response has already been created or deferred.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
defer async
#
defer(*, defer_type=hikari.ResponseType.DEFERRED_MESSAGE_CREATE, ephemeral=None, flags=hikari.UNDEFINED)
Defer the initial response for this context.
Note
The ephemeral state of the first response is decided by whether the deferral is ephemeral.
Parameters:
- defer_type (
DeferredResponseTypesT
, default:DEFERRED_MESSAGE_CREATE
) –The type of deferral this should be.
This may any of the following:
- ResponseType.DEFERRED_MESSAGE_CREATE to indicate that the following up call to BaseContext.edit_initial_response or BaseContext.respond should create a new message.
- ResponseType.DEFERRED_MESSAGE_UPDATE to indicate that the following call to the aforementioned methods should update the existing message.
- ephemeral (
typing.Optional[bool]
, default:None
) –Whether the deferred response should be ephemeral.
Passing True here is a shorthand for including
1 << 64
in the passed flags. - flags (
typing.Union[UndefinedType, int, MessageFlag]
, default:UNDEFINED
) –The flags to use for the initial response.
delete_initial_response async
#
delete_initial_response()
Delete the initial response after invoking this context.
Raises:
-
(LookupError, NotFoundError)
–The last context has no initial response.
delete_last_response async
#
delete_last_response()
Delete the last response after invoking this context.
Raises:
-
(LookupError, NotFoundError)
–The last context has no responses.
edit_initial_response async
#
edit_initial_response(content=hikari.UNDEFINED, *, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Edit the initial response for this context.
Parameters:
- content (
hikari.UndefinedOr[typing.Any]
, default:UNDEFINED
) –If provided, the message content to edit the initial response with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. - delete_after (
typing.Union[timedelta, float, int, None]
, default:None
) –If provided, the seconds after which the response message should be deleted.
Interaction responses can only be deleted within 15 minutes of the interaction being received.
- attachment (
hikari.UndefinedNoneOr[hikari.Resourceish]
, default:UNDEFINED
) –A singular attachment to edit the initial response with.
- attachments (
hikari.UndefinedNoneOr[abc.Sequence[hikari.Resourceish]]
, default:UNDEFINED
) –A sequence of attachments to edit the initial response with.
- component (
hikari.UndefinedNoneOr[hikari.api.ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to set for this message. This component will replace any previously set components and passing None will remove all components.
- components (
hikari.UndefinedNoneOr[abc.Sequence[hikari.api.ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing None or an empty sequence will remove all components.
- embed (
hikari.UndefinedNoneOr[hikari.Embed]
, default:UNDEFINED
) –An embed to replace the initial response with.
- embeds (
hikari.UndefinedNoneOr[abc.Sequence[hikari.Embed]]
, default:UNDEFINED
) –A sequence of embeds to replace the initial response with.
- mentions_everyone (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
- role_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message
–The message that has been edited.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the interaction was received.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
edit_last_response async
#
edit_last_response(content=hikari.UNDEFINED, *, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Edit the last response for this context.
Parameters:
- content (
hikari.UndefinedOr[typing.Any]
, default:UNDEFINED
) –If provided, the content to edit the last response with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. - delete_after (
typing.Union[timedelta, float, int, None]
, default:None
) –If provided, the seconds after which the response message should be deleted.
Interaction responses can only be deleted within 15 minutes of the interaction being received.
- attachment (
hikari.UndefinedNoneOr[hikari.Resourceish]
, default:UNDEFINED
) –A singular attachment to edit the last response with.
- attachments (
hikari.UndefinedNoneOr[abc.Sequence[hikari.Resourceish]]
, default:UNDEFINED
) –A sequence of attachments to edit the last response with.
- component (
hikari.UndefinedNoneOr[hikari.api.ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to set for this message. This component will replace any previously set components and passing None will remove all components.
- components (
hikari.UndefinedNoneOr[abc.Sequence[hikari.api.ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing None or an empty sequence will remove all components.
- embed (
hikari.UndefinedNoneOr[hikari.Embed]
, default:UNDEFINED
) –An embed to replace the last response with.
- embeds (
hikari.UndefinedNoneOr[abc.Sequence[hikari.Embed]]
, default:UNDEFINED
) –A sequence of embeds to replace the last response with.
- mentions_everyone (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
- role_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message
–The message that has been edited.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the slash interaction was received.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
fetch_initial_response async
#
fetch_initial_response()
Fetch the initial response for this context.
Returns:
-
Message
–The initial response's message object.
Raises:
-
(LookupError, NotFoundError)
–The response was not found.
fetch_last_response async
#
fetch_last_response()
Fetch the last response for this context.
Returns:
-
Message
–The most response response's message object.
Raises:
-
(LookupError, NotFoundError)
–The response was not found.
respond async
#
respond(content=hikari.UNDEFINED, *, ensure_result=False, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Respond to this context.
Parameters:
- content (
hikari.UndefinedOr[typing.Any]
, default:UNDEFINED
) –If provided, the message content to respond with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead be treated as an embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. - ensure_result (
bool
, default:False
) –Ensure that this call will always return a message object.
If True then this will always return hikari.Message, otherwise this will return
hikari.Message | None
.It's worth noting that this may lead to an extre request being made under certain scenarios.
- delete_after (
typing.Union[timedelta, float, int, None]
, default:None
) –If provided, the seconds after which the response message should be deleted.
Interaction responses can only be deleted within 15 minutes of the interaction being received.
- attachment (
hikari.UndefinedOr[hikari.Resourceish]
, default:UNDEFINED
) –If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.
- attachments (
hikari.UndefinedOr[abc.Sequence[hikari.Resourceish]]
, default:UNDEFINED
) –If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
- component (
hikari.UndefinedOr[hikari.api.ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to include in this response.
- components (
hikari.UndefinedOr[abc.Sequence[hikari.api.ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects to include in this response.
- embed (
hikari.UndefinedOr[hikari.Embed]
, default:UNDEFINED
) –An embed to respond with.
- embeds (
hikari.UndefinedOr[abc.Sequence[hikari.Embed]]
, default:UNDEFINED
) –A sequence of embeds to respond with.
- mentions_everyone (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
- role_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message | None
–
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the interaction was received.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
ComponentExecutor #
Bases: AbstractComponentExecutor
implementation of a component executor with per-custom ID callbacks.
callbacks property
#
callbacks: collections.Mapping[str, CallbackSig]
Mapping of custom IDs to their set callbacks.
__init__ #
__init__(*, ephemeral_default=False)
Initialise a component executor.
Parameters:
- ephemeral_default (
bool
, default:False
) –Whether this executor's responses should default to being ephemeral.
set_callback #
set_callback(custom_id, callback)
Set the callback for a custom ID.
Parameters:
- custom_id (
str
) –The custom ID to set the callback for.
This will be matched against
interaction.custom_id.split(":", 1)[0]
, allowing metadata to be stored after a":"
. - callback (
CallbackSig
) –The callback to set.
Raises:
-
ValueError
–If
":"
is in the custom ID.
with_callback #
with_callback(custom_id)
Set the callback for a custom ID through a decorator callback.
Parameters:
- custom_id (
str
) –The custom ID to set the callback for.
This will be matched against
interaction.custom_id.split(":", 1)[0]
, allowing metadata to be stored after a":"
.
Returns:
-
abc.abc.Callable[[CallbackSig], CallbackSig]
–Decorator callback used to set a custom ID's callback.
Raises:
-
ValueError
–If
":"
is in the custom ID.
ComponentPaginator #
Bases: ActionColumnExecutor
Standard implementation of an action row executor used for pagination.
This is a convenience class that allows you to easily implement a paginator.
Note
This doesn't use action column's "static" components so any static components added to base-classes of this will appear before the pagination components.
rows property
#
rows: collections.Sequence[hikari.api.MessageActionRowBuilder]
The rows in this column.
__init__ #
__init__(iterator, /, *, authors=None, ephemeral_default=False, triggers=(pagination.LEFT_TRIANGLE, pagination.STOP_SQUARE, pagination.RIGHT_TRIANGLE))
Initialise a component paginator.
Parameters:
- iterator (
abc.Iterator[yuyo.pagination.EntryT] | abc.AsyncIterator[yuyo.pagination.EntryT]
) –The iterator to paginate.
This should be an iterator of yuyo.pagination.Pages.
- authors (
typing.Optional[abc.Iterable[hikari.SnowflakeishOr[hikari.User]]]
, default:None
) –Users who are allowed to use the components this represents.
If no users are provided then the components will be public (meaning that anybody can use it).
- ephemeral_default (
bool
, default:False
) –Whether or not the responses made on contexts spawned from this paginator should default to ephemeral (meaning only the author can see them) unless
flags
is specified on the response method. - triggers (
abc.Collection[str]
, default:(LEFT_TRIANGLE, STOP_SQUARE, RIGHT_TRIANGLE)
) –Collection of the unicode emojis that should trigger this paginator.
As of current the only usable emojis are yuyo.pagination.LEFT_TRIANGLE, yuyo.pagination.RIGHT_TRIANGLE, yuyo.pagination.STOP_SQUARE, yuyo.pagination.LEFT_DOUBLE_TRIANGLE and yuyo.pagination.LEFT_TRIANGLE.
add_builder #
add_builder(builder)
Add a raw component builder to this action column.
This is mostly for adding components where the custom ID is already registered as a separate constant executor.
Parameters:
- builder (
ComponentBuilder
) –The component builder to add to the column.
add_channel_menu #
add_channel_menu(callback, /, *, custom_id=None, channel_types=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a channel select menu to this action column.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- channel_types (
typing.Optional[abc.Sequence[typing.Union[ChannelType, type[hikari.PartialChannel]]]]
, default:None
) –Sequence of the types of channels this select menu should show as options.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
Self
–The action column to enable chained calls.
add_first_button #
add_first_button(*, style=hikari.ButtonStyle.SECONDARY, custom_id=None, emoji=pagination.LEFT_DOUBLE_TRIANGLE, label=hikari.UNDEFINED, is_disabled=False)
Add the jump to first entry button to this paginator.
You should pass triggers=[]
to ComponentPaginator.__init__ before calling this.
Note
These buttons will appear in the order these methods were called in.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- style (
InteractiveButtonTypesT
, default:SECONDARY
) –The button's style.
- emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:LEFT_DOUBLE_TRIANGLE
) –Emoji to display on this button.
- label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Label to display on this button.
- is_disabled (
bool
, default:False
) –Whether to make this button as disabled.
Returns:
-
Self
–To enable chained calls.
add_interactive_button #
add_interactive_button(style, callback, /, *, custom_id=None, emoji=hikari.UNDEFINED, label=hikari.UNDEFINED, is_disabled=False)
Add an interactive button to this action column.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- style (
InteractiveButtonTypesT
) –The button's style.
- callback (
CallbackSig
) –The button's execution callback.
- custom_id (
typing.Optional[str]
, default:None
) –The button's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:UNDEFINED
) –The button's emoji.
- label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –The button's label.
- is_disabled (
bool
, default:False
) –Whether the button should be marked as disabled.
Returns:
-
Self
–The action column to enable chained calls.
add_last_button #
add_last_button(*, style=hikari.ButtonStyle.SECONDARY, custom_id=None, emoji=pagination.RIGHT_DOUBLE_TRIANGLE, label=hikari.UNDEFINED, is_disabled=False)
Add the jump to last entry button to this paginator.
You should pass triggers=[]
to ComponentPaginator.__init__ before calling this.
Note
These buttons will appear in the order these methods were called in.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- style (
InteractiveButtonTypesT
, default:SECONDARY
) –The button's style.
- emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:RIGHT_DOUBLE_TRIANGLE
) –Emoji to display on this button.
Either this or
label
must be provided, but not both. - label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Label to display on this button.
Either this or
emoji
must be provided, but not both. - is_disabled (
bool
, default:False
) –Whether to make this button as disabled.
Returns:
-
Self
–To enable chained calls.
add_link_button #
add_link_button(url, /, *, emoji=hikari.UNDEFINED, label=hikari.UNDEFINED, is_disabled=False)
Add a link button to this action column.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- url (
str
) –The button's url.
- emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:UNDEFINED
) –The button's emoji.
- label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –The button's label.
- is_disabled (
bool
, default:False
) –Whether the button should be marked as disabled.
Returns:
-
Self
–The action column to enable chained calls.
add_mentionable_menu #
add_mentionable_menu(callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a mentionable select menu to this action column.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
Self
–The action column to enable chained calls.
add_next_button #
add_next_button(*, style=hikari.ButtonStyle.SECONDARY, custom_id=None, emoji=pagination.RIGHT_TRIANGLE, label=hikari.UNDEFINED, is_disabled=False)
Add the next entry button to this paginator.
You should pass triggers=[]
to ComponentPaginator.__init__ before calling this.
Note
These buttons will appear in the order these methods were called in.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- style (
InteractiveButtonTypesT
, default:SECONDARY
) –The button's style.
- emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:RIGHT_TRIANGLE
) –Emoji to display on this button.
Either this or
label
must be provided, but not both. - label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Label to display on this button.
Either this or
emoji
must be provided, but not both. - is_disabled (
bool
, default:False
) –Whether to make this button as disabled.
Returns:
-
Self
–To enable chained calls.
add_previous_button #
add_previous_button(*, style=hikari.ButtonStyle.SECONDARY, custom_id=None, emoji=pagination.LEFT_TRIANGLE, label=hikari.UNDEFINED, is_disabled=False)
Add the previous entry button to this paginator.
You should pass triggers=[]
to ComponentPaginator.__init__ before calling this.
Note
These buttons will appear in the order these methods were called in.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- style (
InteractiveButtonTypesT
, default:SECONDARY
) –The button's style.
- emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:LEFT_TRIANGLE
) –Emoji to display on this button.
Either this or
label
must be provided, but not both. - label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Label to display on this button.
Either this or
emoji
must be provided, but not both. - is_disabled (
bool
, default:False
) –Whether to make this button as disabled.
Returns:
-
Self
–To enable chained calls.
add_role_menu #
add_role_menu(callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a role select menu to this action column.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
Self
–The action column to enable chained calls.
add_select_menu #
add_select_menu(type_, callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a select menu to this action column.
The following methods should be used instead:
add_static_builder classmethod
#
add_static_builder(builder)
Add a raw component builder to all subclasses and instances of this column.
This is mostly for adding components where the custom ID is already registered as a separate constant executor.
Parameters:
- builder (
ComponentBuilder
) –The component builder to add to the column class.
add_static_channel_menu classmethod
#
add_static_channel_menu(callback, /, *, custom_id=None, channel_types=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a channel select menu to all subclasses and instances of this action column class.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- channel_types (
typing.Optional[abc.Sequence[typing.Union[ChannelType, type[hikari.PartialChannel]]]]
, default:None
) –Sequence of the types of channels this select menu should show as options.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
type[Self]
–The action column class to enable chained calls.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
add_static_interactive_button classmethod
#
add_static_interactive_button(style, callback, /, *, custom_id=None, emoji=hikari.UNDEFINED, label=hikari.UNDEFINED, is_disabled=False)
Add an interactive button to all subclasses and instances of this action column class.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- style (
InteractiveButtonTypesT
) –The button's style.
- callback (
CallbackSig
) –The button's execution callback.
- custom_id (
typing.Optional[str]
, default:None
) –The button's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:UNDEFINED
) –The button's emoji.
- label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –The button's label.
- is_disabled (
bool
, default:False
) –Whether the button should be marked as disabled.
Returns:
-
type[Self]
–The action column class to enable chained calls.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
add_static_link_button classmethod
#
add_static_link_button(url, /, *, emoji=hikari.UNDEFINED, label=hikari.UNDEFINED, is_disabled=False)
Add a link button to all subclasses and instances of this action column class.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- url (
str
) –The button's url.
- emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:UNDEFINED
) –The button's emoji.
- label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –The button's label.
- is_disabled (
bool
, default:False
) –Whether the button should be marked as disabled.
Returns:
-
type[Self]
–The action column class to enable chained calls.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
add_static_mentionable_menu classmethod
#
add_static_mentionable_menu(callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a mentionable select menu to all subclasses and instances of this action column class.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
type[Self]
–The action column class to enable chained calls.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
add_static_role_menu classmethod
#
add_static_role_menu(callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a role select menu to all subclasses and instances of this action column class.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
type[Self]
–The action column class to enable chained calls.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
add_static_select_menu classmethod
#
add_static_select_menu(type_, callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a select menu to all subclasses and instances of this action column class.
The following class methods should be used instead:
add_static_text_menu classmethod
#
add_static_text_menu(callback, /, *, custom_id=None, options=(), placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a text select menu to all subclasses and instances of this action column class.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - options (
abc.Sequence[hikari.api.SelectOptionBuilder]
, default:()
) –The text select's options.
These can also be added by calling TextSelectMenuBuilder.add_option.
- placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
TextSelectMenuBuilder
–Builder for the added text select menu.
TextSelectMenuBuilder.add_option should be used to add options to this select menu.
And the parent action column can be accessed by calling TextSelectMenuBuilder.parent.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
add_static_user_menu classmethod
#
add_static_user_menu(callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a user select menu to all subclasses and instances of this action column class.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
type[Self]
–The action column class to enable chained calls.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
add_stop_button #
add_stop_button(*, style=hikari.ButtonStyle.DANGER, custom_id=None, emoji=pagination.BLACK_CROSS, label=hikari.UNDEFINED, is_disabled=False)
Add the stop button to this paginator.
You should pass triggers=[]
to ComponentPaginator.__init__ before calling this.
Note
These buttons will appear in the order these methods were called in.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- style (
InteractiveButtonTypesT
, default:DANGER
) –The button's style.
- emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:BLACK_CROSS
) –Emoji to display on this button.
Either this or
label
must be provided, but not both. - label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Label to display on this button.
Either this or
emoji
must be provided, but not both. - is_disabled (
bool
, default:False
) –Whether to make this button as disabled.
Returns:
-
Self
–To enable chained calls.
add_text_menu #
add_text_menu(callback, /, *, custom_id=None, options=(), placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a text select menu to this action column.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - options (
abc.Sequence[hikari.api.SelectOptionBuilder]
, default:()
) –The text select's options.
These can also be added by calling TextSelectMenuBuilder.add_option.
- placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
TextSelectMenuBuilder
–Builder for the added text select menu.
TextSelectMenuBuilder.add_option should be used to add options to this select menu.
And the parent action column can be accessed by calling TextSelectMenuBuilder.parent.
add_user_menu #
add_user_menu(callback, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a user select menu to this action column.
Parameters:
- callback (
CallbackSig
) –Callback which is called when this select menu is used.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Returns:
-
Self
–The action column to enable chained calls.
get_next_entry async
#
get_next_entry()
Get the next entry in this paginator.
This is generally helpful for making the message which the paginator will be based off and will still internally store the entry and increment the position of the paginator.
Examples:
paginator = yuyo.ComponentPaginator(pages, authors=[ctx.author.id])
first_response = await paginator.get_next_entry()
assert first_response
message = await ctx.respond(components=paginator.rows, **first_response.to_kwargs(), ensure_result=True)
component_client.register_executor(paginator, message=message)
Returns:
with_channel_menu #
with_channel_menu(callback=None, /, *, custom_id=None, channel_types=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a channel select menu to this action column through a decorator call.
Parameters:
- channel_types (
typing.Optional[abc.Sequence[typing.Union[ChannelType, type[hikari.PartialChannel]]]]
, default:None
) –Sequence of the types of channels this select menu should show as options.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
with_interactive_button #
with_interactive_button(style, /, *, custom_id=None, emoji=hikari.UNDEFINED, label=hikari.UNDEFINED, is_disabled=False)
Add an interactive button to this action column through a decorator call.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- style (
InteractiveButtonTypesT
) –The button's style.
- custom_id (
typing.Optional[str]
, default:None
) –The button's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:UNDEFINED
) –The button's emoji.
- label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –The button's label.
- is_disabled (
bool
, default:False
) –Whether the button should be marked as disabled.
with_mentionable_menu #
with_mentionable_menu(callback=None, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a mentionable select menu to this action column through a decorator call.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
with_role_menu #
with_role_menu(callback=None, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a role select menu to this action column through a decorator call.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
with_static_channel_menu classmethod
#
with_static_channel_menu(callback=None, /, *, custom_id=None, channel_types=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a channel select menu to this action column class through a decorator call.
Parameters:
- channel_types (
typing.Optional[abc.Sequence[typing.Union[ChannelType, type[hikari.PartialChannel]]]]
, default:None
) –Sequence of the types of channels this select menu should show as options.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
with_static_interactive_button classmethod
#
with_static_interactive_button(style, /, *, custom_id=None, emoji=hikari.UNDEFINED, label=hikari.UNDEFINED, is_disabled=False)
Add a static interactive button to this action column class through a decorator call.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- style (
InteractiveButtonTypesT
) –The button's style.
- custom_id (
typing.Optional[str]
, default:None
) –The button's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:UNDEFINED
) –The button's emoji.
- label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –The button's label.
- is_disabled (
bool
, default:False
) –Whether the button should be marked as disabled.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
with_static_mentionable_menu classmethod
#
with_static_mentionable_menu(callback=None, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a static mentionable select menu to this action column class through a decorator call.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
with_static_role_menu classmethod
#
with_static_role_menu(callback=None, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a static role select menu to this action column class through a decorator call.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
with_static_text_menu classmethod
#
with_static_text_menu(callback=None, /, *, custom_id=None, options=(), placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a text select menu to this action column class through a decorator call.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - options (
abc.Sequence[hikari.api.SelectOptionBuilder]
, default:()
) –The text select's options.
These can also be added using [yuyo.components.with_option].
- placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
with_static_user_menu classmethod
#
with_static_user_menu(callback=None, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a static user select menu to this action column class through a decorator call.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Raises:
-
RuntimeError
–When called directly on ActionColumnExecutor (rather than on a subclass).
with_text_menu #
with_text_menu(callback=None, /, *, custom_id=None, options=(), placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a text select menu to this action column through a decorator callback.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - options (
abc.Sequence[hikari.api.SelectOptionBuilder]
, default:()
) –The text select's options.
These can also be added using components.with_option.
- placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
with_user_menu #
with_user_menu(callback=None, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Add a user select menu to this action column through a decorator call.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a UUID and cannot be longer than 100 characters.
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
ExecutorClosed #
Bases: Exception
Error used to indicate that an executor is now closed during execution.
__init__ #
__init__(*, already_closed=True)
Initialise an executor closed error.
Parameters:
- already_closed (
bool
, default:True
) –Whether this error is a result of the executor having been in a closed state when it was called.
If so then this will lead to a "timed-out" message being sent as the initial response.
InteractionError #
Bases: Exception
Error which is sent as a response to a modal or component call.
__init__ #
__init__(content=hikari.UNDEFINED, *, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Initialise an interaction error.
Parameters:
- content (
hikari.UndefinedOr[typing.Any]
, default:UNDEFINED
) –If provided, the message content to respond with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead be treated as an embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. - delete_after (
typing.Union[timedelta, float, int, None]
, default:None
) –If provided, the seconds after which the response message should be deleted.
Interaction responses can only be deleted within 15 minutes of the interaction being received.
- attachment (
hikari.UndefinedOr[hikari.Resourceish]
, default:UNDEFINED
) –A singular attachment to respond with.
- attachments (
hikari.UndefinedOr[abc.Sequence[hikari.Resourceish]]
, default:UNDEFINED
) –A sequence of attachments to respond with.
- component (
hikari.UndefinedOr[hikari.api.ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to include in this response.
- components (
hikari.UndefinedOr[abc.Sequence[hikari.api.ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects to include in this response.
- embed (
hikari.UndefinedOr[hikari.Embed]
, default:UNDEFINED
) –An embed to respond with.
- embeds (
hikari.UndefinedOr[abc.Sequence[hikari.Embed]]
, default:UNDEFINED
) –A sequence of embeds to respond with.
- mentions_everyone (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
- role_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool, UndefinedType]
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Raises:
-
ValueError
–Raised for any of the following reasons:
- When both
attachment
andattachments
are provided. - When both
component
andcomponents
are passed. - When both
embed
andembeds
are passed. - If more than 100 entries are passed for
role_mentions
. - If more than 100 entries are passed for
user_mentions
.
- When both
send async
#
send(ctx, /, *, ensure_result=False)
Send this error as an interaction response.
Parameters:
- ctx (
typing.Union[BaseContext[hikari.ComponentInteraction], BaseContext[hikari.ModalInteraction]]
) –The interaction context to respond to.
- ensure_result (
bool
, default:False
) –Ensure that this call will always return a message object.
If True then this will always return hikari.Message, otherwise this will return
hikari.Message | None
.It's worth noting that this may lead to an extra request being made under certain scenarios.
Raises:
-
ValueError
–If
delete_after
would be more than 15 minutes after the interaction was received. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
SingleExecutor #
Bases: AbstractComponentExecutor
Component executor with a single callback.
__init__ #
__init__(custom_id, callback, /, *, ephemeral_default=False)
Initialise an executor with a single callback.
Parameters:
- custom_id (
str
) –The custom ID this executor is triggered for.
This will be matched against
interaction.custom_id.split(":", 1)[0]
, allowing metadata to be stored after a":"
. - callback (
CallbackSig
) –The executor's callback.
- ephemeral_default (
bool
, default:False
) –Whether this executor's responses should default to being ephemeral.
Raises:
-
ValueError
–If
":"
is in the custom ID.
WaitForExecutor #
Bases: AbstractComponentExecutor
, AbstractTimeout
Component executor used to wait for a single component interaction.
This should also be passed for timeout=
.
Examples:
message = await ctx.respond("hi, pick an option", components=[...], ensure_result=True)
executor = yuyo.components.WaitFor(authors=[ctx.author.id], timeout=datetime.timedelta(seconds=30))
component_client.register_executor(executor, message=message, timeout=executor)
try:
result = await executor.wait_for()
except asyncio.TimeoutError:
await ctx.respond("timed out")
else:
await result.respond("...")
__init__ #
__init__(*, authors=None, ephemeral_default=False, timeout)
Initialise a wait for executor.
Parameters:
- authors (
typing.Optional[abc.Iterable[hikari.SnowflakeishOr[hikari.User]]]
, default:None
) –Users who are allowed to use the components this represents.
If no users are provided then the components will be public (meaning that anybody can use it).
- ephemeral_default (
bool
, default:False
) –Whether or not the responses made on contexts spawned from this paginator should default to ephemeral (meaning only the author can see them) unless
flags
is specified on the response method. - timeout (
typing.Optional[datetime.timedelta]
) –How long this should wait for a matching component interaction until it times-out.
wait_for async
#
wait_for()
Wait for the next matching interaction.
Returns:
-
Context
–The next matching interaction.
Raises:
-
RuntimeError
–If the executor is already being waited for.
-
TimeoutError
–If the timeout is reached.
as_channel_menu #
as_channel_menu(callback=None, /, *, custom_id=None, channel_types=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Declare a channel select menu on an action column class.
Parameters:
- channel_types (
typing.Optional[abc.Sequence[typing.Union[ChannelType, type[hikari.PartialChannel]]]]
, default:None
) –Sequence of the types of channels this select menu should show as options.
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a constant ID that's generated from the path to the decorated callback (which includes the class and module qualnames).
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata and the custom ID cannot be longer than 100 characters in total. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Examples:
class CustomColumn(components.ActionColumnExecutor):
@components.as_channel_menu(channel_types=[hikari.TextableChannel])
async def on_channel_menu(self, ctx: components.Context) -> None:
...
as_interactive_button #
as_interactive_button(style, /, *, custom_id=None, emoji=hikari.UNDEFINED, label=hikari.UNDEFINED, is_disabled=False)
Declare an interactive button on an action column class.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- style (
InteractiveButtonTypesT
) –The button's style.
- custom_id (
typing.Optional[str]
, default:None
) –The button's custom ID.
Defaults to a constant ID that's generated from the path to the decorated callback (which includes the class and module qualnames).
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata and the custom ID cannot be longer than 100 characters in total. - emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:UNDEFINED
) –The button's emoji.
- label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –The button's label.
- is_disabled (
bool
, default:False
) –Whether the button should be marked as disabled.
Examples:
class CustomColumn(components.ActionColumnExecutor):
@components.as_interactive_button(ButtonStyle.DANGER, label="label")
async def on_button(self, ctx: components.Context) -> None:
...
as_mentionable_menu #
as_mentionable_menu(callback=None, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Declare a mentionable select menu on an action column class.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a constant ID that's generated from the path to the decorated callback (which includes the class and module qualnames).
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata and the custom ID cannot be longer than 100 characters in total. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Examples:
class CustomColumn(components.ActionColumnExecutor):
@components.as_mentionable_menu(max_values=5)
async def on_select_menu(self, ctx: components.Context) -> None:
...
as_role_menu #
as_role_menu(callback=None, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Declare a role select menu on an action column class.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a constant ID that's generated from the path to the decorated callback (which includes the class and module qualnames).
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata and the custom ID cannot be longer than 100 characters in total. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Examples:
class CustomColumn(components.ActionColumnExecutor):
@components.as_role_menu(max_values=5)
async def on_select_menu(self, ctx: components.Context) -> None:
...
as_select_menu #
as_select_menu(type_, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Declare a select menu on an action column class.
The following decorators should be used instead:
as_single_executor #
as_single_executor(custom_id, /, *, ephemeral_default=False)
Create an executor with a single callback by decorating the callback.
Parameters:
- custom_id (
str
) –The custom ID this executor is triggered for.
This will be matched against
interaction.custom_id.split(":", 1)[0]
, allowing metadata to be stored after a":"
. - ephemeral_default (
bool
, default:False
) –Whether this executor's responses should default to being ephemeral.
Returns:
-
SingleExecutor
–The created executor.
as_text_menu #
as_text_menu(callback=None, /, *, custom_id=None, options=(), placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Declare a text select menu on an action column class.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a constant ID that's generated from the path to the decorated callback (which includes the class and module qualnames).
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata and the custom ID cannot be longer than 100 characters in total. - options (
abc.Sequence[hikari.api.SelectOptionBuilder]
, default:()
) –The text select's options.
These can also be added by using components.with_option.
- placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Examples:
class CustomColumn(components.ActionColumnExecutor):
@components.with_option("label", "value")
@components.as_text_menu
async def on_text_menu(self, ctx: components.Context) -> None:
...
as_user_menu #
as_user_menu(callback=None, /, *, custom_id=None, placeholder=hikari.UNDEFINED, min_values=0, max_values=1, is_disabled=False)
Declare a user select menu on an action column class.
Parameters:
- custom_id (
typing.Optional[str]
, default:None
) –The select menu's custom ID.
Defaults to a constant ID that's generated from the path to the decorated callback (which includes the class and module qualnames).
Only
custom_id.split(":", 1)[0]
will be used to match against interactions. Anything after":"
is metadata and the custom ID cannot be longer than 100 characters in total. - placeholder (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –Placeholder text to show when no entries have been selected.
- min_values (
int
, default:0
) –The minimum amount of entries which need to be selected.
- max_values (
int
, default:1
) –The maximum amount of entries which can be selected.
- is_disabled (
bool
, default:False
) –Whether this select menu should be marked as disabled.
Examples:
class CustomColumn(components.ActionColumnExecutor):
@components.as_user_menu(max_values=5)
async def on_select_menu(self, ctx: components.Context) -> None:
...
builder #
builder(builder)
Add a raw component builder to a column through a descriptor.
This is mostly for adding components where the custom ID is already registered as a separate constant executor.
Parameters:
- builder (
ComponentBuilder
) –The component builder to add to the column.
Examples:
class CustomColumn(components.ActionColumnExecutor):
link_button = components.builder(hikari.impl.InteractiveButtonBuilder(
style=hikari.ButtonStyle.PRIMARY, custom_id="CUSTOM_ID", label="yeet"
))
column_template #
column_template(ephemeral_default=False)
Create a column template through a decorator callback.
The returned type acts like any other slotted action column subclass and supports the same add_static
class methods and initialisation signature.
Parameters:
- ephemeral_default (
bool
, default:False
) –Whether this column template's responses should default to ephemeral.
Returns:
-
type[ActionColumnExecutor]
–The new column template.
link_button #
link_button(url, /, *, emoji=hikari.UNDEFINED, label=hikari.UNDEFINED, is_disabled=False)
Declare an link button on an action column class.
Either emoji
xor label
must be provided to be the button's displayed label.
Parameters:
- url (
str
) –The button's url.
- emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:UNDEFINED
) –The button's emoji.
- label (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –The button's label.
- is_disabled (
bool
, default:False
) –Whether the button should be marked as disabled.
Examples:
class CustomColumn(components.ActionColumnExecutor):
link_button = components.link_button("https://example.com", label="label")
with_option #
with_option(label, value, /, *, description=hikari.UNDEFINED, emoji=hikari.UNDEFINED, is_default=False)
Add an option to a text select menu through a decorator call.
Parameters:
- label (
str
) –The option's label.
- value (
str
) –The option's value.
- description (
hikari.UndefinedOr[str]
, default:UNDEFINED
) –The option's description.
- emoji (
typing.Union[Snowflakeish, Emoji, str, UndefinedType]
, default:UNDEFINED
) –Emoji to display for the option.
- is_default (
bool
, default:False
) –Whether the option should be marked as selected by default.
Examples:
class Column(components.AbstractColumnExecutor):
@components.with_option("other label", "other value")
@components.with_option("label", "value")
@components.as_text_menu
async def on_text_menu(self, ctx: components.Context) -> None:
...
column = components.ActionColumnExecutor()
@components.with_option("name3", "value3")
@components.with_option("name2", "value2")
@components.with_option("name1", "value1")
@column.with_text_menu
async def on_text_menu(ctx: components.Context) -> None:
...