hikari.interactions.modal_interactions#
Models and enums used for Discord’s Modals interaction flow.
Module Contents#
- class hikari.interactions.modal_interactions.ModalInteraction[source]#
Bases:
hikari.interactions.base_interactions.MessageResponseMixin
[ModalResponseTypesT
]Represents a modal interaction on Discord.
- app_permissions: hikari.permissions.Permissions | None[source]#
Permissions the bot has in this interaction’s channel if it’s in a guild.
- channel_id: hikari.snowflakes.Snowflake[source]#
ID of the channel this modal interaction event was triggered in.
- guild_id: hikari.snowflakes.Snowflake | None[source]#
ID of the guild this modal interaction event was triggered in.
This will be
None
for modal interactions triggered in DMs.
- guild_locale: str | None[source]#
The preferred language of the guild this modal interaction was triggered in.
This will be
None
for modal interactions triggered in DMs.Note
This value can usually only be changed if
COMMUNITY
is inhikari.guilds.Guild.features
for the guild and will otherwise default toen-US
.
- member: hikari.interactions.base_interactions.InteractionMember | None[source]#
The member who triggered this modal interaction.
This will be
None
for modal interactions triggered in DMs.Note
This member object comes with the extra field
permissions
which contains the member’s permissions in the current channel.
- message: hikari.messages.Message | None[source]#
The message whose component triggered the modal.
This will be None if the modal was a response to a command.
- user: hikari.users.User[source]#
The user who triggered this modal interaction.
- build_deferred_response()[source]#
Get a deferred message response builder for use in the REST server flow.
Note
For interactions received over the gateway
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:
hikari.api.special_endpoints.InteractionDeferredBuilder
Deferred interaction message response builder object.
- build_response()[source]#
Get a message response builder for use in the REST server flow.
Note
For interactions received over the gateway
ModalInteraction.create_initial_response
should be used to set the interaction response message.- Returns:
hikari.api.special_endpoints.InteractionMessageBuilder
Interaction message response builder object.
Examples
async def handle_modal_interaction(interaction: ModalInteraction) -> InteractionMessageBuilder: return ( interaction .build_response() .add_embed(Embed(description="Hi there")) .set_content("Konnichiwa") )
- async fetch_channel()[source]#
Fetch the guild channel this interaction was triggered in.
- Returns:
hikari.channels.TextableChannel
The requested partial channel derived object of the channel this interaction was triggered in.
- Raises:
hikari.errors.UnauthorizedError
If you are unauthorized to make the request (invalid/missing token).
hikari.errors.ForbiddenError
If you are missing the
READ_MESSAGES
permission in the channel.hikari.errors.NotFoundError
If the channel is not found.
hikari.errors.RateLimitTooLongError
Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request.hikari.errors.RateLimitTooLongError
Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request.hikari.errors.InternalServerError
If an internal error occurs on Discord while handling the request.
- async fetch_guild()[source]#
Fetch the guild this interaction happened in.
- Returns:
typing.Optional
[hikari.guilds.RESTGuild
]Object of the guild this interaction happened in or
None
if this occurred within a DM channel.
- Raises:
hikari.errors.ForbiddenError
If you are not part of the guild.
hikari.errors.NotFoundError
If the guild is not found.
hikari.errors.UnauthorizedError
If you are unauthorized to make the request (invalid/missing token).
hikari.errors.RateLimitTooLongError
Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request.hikari.errors.InternalServerError
If an internal error occurs on Discord while handling the request.
- get_channel()[source]#
Get the guild channel this interaction was triggered in from the cache.
Note
This will always return
None
for interactions triggered in a DM channel.- Returns:
typing.Optional
[hikari.channels.TextableGuildChannel
]The object of the guild channel that was found in the cache or
None
.
- get_guild()[source]#
Get the object of the guild this interaction was triggered in from the cache.
- Returns:
typing.Optional
[hikari.guilds.GatewayGuild
]The object of the guild if found, else
None
.