Skip to content

hikari.interactions.modal_interactions#

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

ModalInteraction #

Bases: MessageResponseMixin[ModalResponseTypesT], PremiumResponseMixin

Represents a modal interaction on Discord.

components class-attribute instance-attribute #

components: Sequence[ModalActionRowComponent] = field(
    eq=False, hash=False, repr=True
)

Components in the modal.

custom_id class-attribute instance-attribute #

custom_id: str = field(eq=False, hash=False, repr=True)

The custom id of the modal.

message class-attribute instance-attribute #

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

The message whose component triggered the modal.

This will be None if the modal was a response to a command.

build_deferred_response #

build_deferred_response() -> InteractionDeferredBuilder

Get a deferred message response builder for use in the REST server flow.

Note

For interactions received over the gateway hikari.interactions.modal_interactions.ModalInteraction.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.

RETURNS DESCRIPTION
InteractionDeferredBuilder

Deferred interaction message response builder object.

build_response #

build_response() -> InteractionMessageBuilder

Get a message response builder for use in the REST server flow.

Note

For interactions received over the gateway hikari.interactions.modal_interactions.ModalInteraction.create_initial_response should be used to set the interaction response message.

Examples:

async def handle_modal_interaction(
    interaction: ModalInteraction,
) -> InteractionMessageBuilder:
    return (
        interaction.build_response()
        .add_embed(Embed(description="Hi there"))
        .set_content("Konnichiwa")
    )
RETURNS DESCRIPTION
InteractionMessageBuilder

Interaction message response builder object.

ModalInteractionMetadata #

Bases: PartialInteractionMetadata

The interaction metadata for a modal initiated message.

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.

triggering_interaction_metadata class-attribute instance-attribute #

triggering_interaction_metadata: PartialInteractionMetadata = field(
    eq=False, hash=False, repr=True
)

The metadata for the interaction that was used to open the modal.