Skip to content

hikari.interactions.component_interactions#

Models and enums used for Discord's Components interaction flow.

ComponentResponseTypesT module-attribute #

ComponentResponseTypesT = Union[
    _ImmediateTypesT, _DeferredTypesT
]

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 #

custom_id: str = field(eq=False)

Developer defined ID of the component which triggered this interaction.

message class-attribute instance-attribute #

message: Message = field(eq=False, repr=False)

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 #

values: Sequence[str] = field(eq=False)

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_

TYPE: _DeferredTypesT

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_

TYPE: _ImmediateTypesT

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 #

interacted_message_id: Snowflake = field(
    eq=False, hash=False, repr=True
)

The ID of the message that contained the interactive component

original_response_message_id class-attribute instance-attribute #

original_response_message_id: Snowflake | None = field(
    eq=False, hash=False, repr=True
)

The ID of the original response message, present only on follow-up messages.