hikari.interactions.modal_interactions
#
Models and enums used for Discord's Modals interaction flow.
ModalResponseTypesT module-attribute
#
ModalResponseTypesT = Literal[MESSAGE_CREATE, 4, DEFERRED_MESSAGE_CREATE, 5, MESSAGE_UPDATE, 7, DEFERRED_MESSAGE_UPDATE, 6]
Type-hint of the response types which are valid for a modal interaction.
The following types are valid for this:
ModalInteraction #
Bases: MessageResponseMixin[ModalResponseTypesT]
, PremiumResponseMixin
Represents a modal interaction on Discord.
app_permissions class-attribute
instance-attribute
#
app_permissions: Optional[Permissions] = field(eq=False, hash=False, repr=False)
Permissions the bot has in this interaction's channel if it's in a guild.
channel_id class-attribute
instance-attribute
#
ID of the channel this modal interaction event was triggered in.
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
#
The custom id of the modal.
entitlements class-attribute
instance-attribute
#
entitlements: Sequence[Entitlement] = field(eq=False, hash=False, repr=True)
For monetized apps, any entitlements for the invoking user, represents access to SKUs.
guild_id class-attribute
instance-attribute
#
ID of the guild this modal interaction event was triggered in.
This will be None
for modal interactions triggered in DMs.
guild_locale class-attribute
instance-attribute
#
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 hikari.guilds.GuildFeature.COMMUNITY
is in hikari.guilds.Guild.features
for the guild and will otherwise default to hikari.locales.Locale.EN_US
.
locale class-attribute
instance-attribute
#
The selected language of the user who triggered this modal interaction.
member class-attribute
instance-attribute
#
member: Optional[InteractionMember] = field(eq=False, hash=False, repr=True)
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 class-attribute
instance-attribute
#
The message whose component triggered the modal.
This will be None
if the modal was a response to a command.
user class-attribute
instance-attribute
#
The user who triggered this modal interaction.
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. |
fetch_channel async
#
fetch_channel() -> TextableChannel
Fetch the guild channel this interaction was triggered in.
RETURNS | DESCRIPTION |
---|---|
TextableChannel | The requested partial channel derived object of the channel this interaction was triggered in. |
RAISES | DESCRIPTION |
---|---|
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError | If you are missing the |
NotFoundError | If the channel is not found. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
fetch_guild async
#
Fetch the guild this interaction happened in.
RETURNS | DESCRIPTION |
---|---|
Optional[RESTGuild] | Object of the guild this interaction happened in or |
RAISES | DESCRIPTION |
---|---|
ForbiddenError | If you are not part of the guild. |
NotFoundError | If the guild is not found. |
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
get_channel #
get_channel() -> Optional[TextableGuildChannel]
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 | DESCRIPTION |
---|---|
Optional[TextableGuildChannel] | The object of the guild channel that was found in the cache or |
get_guild #
get_guild() -> Optional[GatewayGuild]
Get the object of the guild this interaction was triggered in from the cache.
RETURNS | DESCRIPTION |
---|---|
Optional[GatewayGuild] | The object of the guild if found, else |