hikari.interactions.component_interactions
#
Models and enums used for Discord's Components interaction flow.
COMPONENT_RESPONSE_TYPES module-attribute
#
COMPONENT_RESPONSE_TYPES: Final[
AbstractSet[ComponentResponseTypesT]
] = frozenset([*_DEFERRED_TYPES, *_IMMEDIATE_TYPES])
Set of the response types which are valid for a component interaction.
This includes:
ComponentResponseTypesT module-attribute
#
ComponentResponseTypesT = Union[
_ImmediateTypesT, _DeferredTypesT
]
Type-hint of the response types which are valid for a component interaction.
The following types are valid for this:
ComponentInteraction #
Bases: MessageResponseMixin[ComponentResponseTypesT]
, ModalResponseMixin
, PremiumResponseMixin
Represents a component interaction on Discord.
component_type class-attribute
instance-attribute
#
component_type: ComponentType | int = field(eq=False)
The type of component which triggers this interaction.
Note
This will never be hikari.components.ButtonStyle.LINK
as link buttons don't trigger interactions.
custom_id class-attribute
instance-attribute
#
Developer defined ID of the component which triggered this interaction.
message class-attribute
instance-attribute
#
Object of the message the components for this interaction are attached to.
resolved class-attribute
instance-attribute
#
resolved: ResolvedOptionData | None = field(
eq=False, hash=False, repr=False
)
Mappings of the objects resolved for the provided command options.
values class-attribute
instance-attribute
#
Sequence of the values which were selected for a select menu component.
build_deferred_response #
build_deferred_response(
type_: _DeferredTypesT,
) -> InteractionDeferredBuilder
Get a deferred message response builder for use in the REST server flow.
Note
For interactions received over the gateway hikari.interactions.component_interactions.ComponentInteraction.create_initial_response
should be used to set the interaction response message.
Note
Unlike hikari.api.special_endpoints.InteractionMessageBuilder
, the result of this call can be returned as is without any modifications being made to it.
PARAMETER | DESCRIPTION |
---|---|
type_ | The type of deferred response this should be. This may be one of the following: TYPE: |
RETURNS | DESCRIPTION |
---|---|
InteractionDeferredBuilder | Deferred interaction message response builder object. |
build_response #
build_response(
type_: _ImmediateTypesT,
) -> InteractionMessageBuilder
Get a message response builder for use in the REST server flow.
Note
For interactions received over the gateway hikari.interactions.component_interactions.ComponentInteraction.create_initial_response
should be used to set the interaction response message.
PARAMETER | DESCRIPTION |
---|---|
type_ | The type of immediate response this should be. This may be one of the following: TYPE: |
Examples:
async def handle_component_interaction(
interaction: ComponentInteraction,
) -> InteractionMessageBuilder:
return (
interaction.build_response(ResponseType.MESSAGE_UPDATE)
.add_embed(Embed(description="Hi there"))
.set_content("Konnichiwa")
)
RETURNS | DESCRIPTION |
---|---|
InteractionMessageBuilder | Interaction message response builder object. |
ComponentInteractionMetadata #
Bases: PartialInteractionMetadata
The interaction metadata for a component belonging to a message.
interacted_message_id class-attribute
instance-attribute
#
The ID of the message that contained the interactive component