Skip to content

hikari.interactions.base_interactions#

Base classes and enums inherited and used throughout the interactions flow.

DEFERRED_RESPONSE_TYPES module-attribute #

Set of the response types which are valid for deferred messages responses.

This includes the following:

DeferredResponseTypesT module-attribute #

DeferredResponseTypesT = Literal[DEFERRED_MESSAGE_CREATE, 5, DEFERRED_MESSAGE_UPDATE, 6]

Type-hint of the response types which are valid for deferred messages responses.

The following are valid for this:

MESSAGE_RESPONSE_TYPES module-attribute #

Set of the response types which are valid for message responses.

This includes the following:

MessageResponseTypesT module-attribute #

MessageResponseTypesT = Literal[MESSAGE_CREATE, 4, MESSAGE_UPDATE, 7]

Type-hint of the response types which are valid for message responses.

The following are valid for this:

InteractionChannel #

Bases: PartialChannel

Represents partial channels returned as resolved entities on interactions.

permissions class-attribute instance-attribute #

permissions: Permissions = field(eq=False, hash=False, repr=True)

Permissions the command's executor has in this channel.

InteractionMember #

Bases: Member

Model of the member who triggered an interaction.

Unlike hikari.guilds.Member, this object comes with an extra hikari.interactions.base_interactions.InteractionMember.permissions field.

permissions class-attribute instance-attribute #

permissions: Permissions = field(eq=False, hash=False, repr=False)

Permissions the member has in the current channel.

InteractionType #

Bases: int, Enum

The type of an interaction.

APPLICATION_COMMAND class-attribute instance-attribute #

APPLICATION_COMMAND = 2

An interaction triggered by a user calling an application command.

AUTOCOMPLETE class-attribute instance-attribute #

AUTOCOMPLETE = 4

An interaction triggered by a user typing in a slash command option.

MESSAGE_COMPONENT class-attribute instance-attribute #

MESSAGE_COMPONENT = 3

An interaction triggered by a user calling a message component.

MODAL_SUBMIT class-attribute instance-attribute #

MODAL_SUBMIT = 5

An interaction triggered by a user submitting a modal.

MessageResponseMixin #

Bases: PartialInteraction, Generic[_CommandResponseTypesT]

Mixin' class for all interaction types which can be responded to with a message.

create_initial_response async #

create_initial_response(response_type: _CommandResponseTypesT, content: UndefinedOr[Any] = undefined.UNDEFINED, *, flags: Union[int, MessageFlag, UndefinedType] = undefined.UNDEFINED, tts: UndefinedOr[bool] = undefined.UNDEFINED, attachment: UndefinedNoneOr[Resourceish] = undefined.UNDEFINED, attachments: UndefinedNoneOr[Sequence[Resourceish]] = undefined.UNDEFINED, component: UndefinedNoneOr[ComponentBuilder] = undefined.UNDEFINED, components: UndefinedNoneOr[Sequence[ComponentBuilder]] = undefined.UNDEFINED, embed: UndefinedNoneOr[Embed] = undefined.UNDEFINED, embeds: UndefinedNoneOr[Sequence[Embed]] = undefined.UNDEFINED, mentions_everyone: UndefinedOr[bool] = undefined.UNDEFINED, user_mentions: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]] = undefined.UNDEFINED, role_mentions: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]] = undefined.UNDEFINED) -> None

Create the initial response for this interaction.

Warning

Calling this on an interaction which already has an initial response will result in this raising a hikari.errors.NotFoundError. This includes if the REST interaction server has already responded to the request.

PARAMETER DESCRIPTION
response_type

The type of interaction response this is.

TYPE: _CommandResponseTypesT

content

If provided, the message contents. If hikari.undefined.UNDEFINED, then nothing will be sent in the content. Any other value here will be cast to a str.

If this is a hikari.embeds.Embed and no embed nor embeds kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.

TYPE: UndefinedOr[Any] DEFAULT: UNDEFINED

attachment

If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.

TYPE: UndefinedNoneOr[Resourceish] DEFAULT: UNDEFINED

attachments

If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.

TYPE: UndefinedNoneOr[Sequence[Resourceish]] DEFAULT: UNDEFINED

component

If provided, builder object of the component to include in this message.

TYPE: UndefinedNoneOr[ComponentBuilder] DEFAULT: UNDEFINED

components

If provided, a sequence of the component builder objects to include in this message.

TYPE: UndefinedNoneOr[Sequence[ComponentBuilder]] DEFAULT: UNDEFINED

embed

If provided, the message embed.

TYPE: UndefinedNoneOr[Embed] DEFAULT: UNDEFINED

embeds

If provided, the message embeds.

TYPE: UndefinedNoneOr[Sequence[Embed]] DEFAULT: UNDEFINED

flags

If provided, the message flags this response should have.

As of writing the only message flags which can be set here are hikari.messages.MessageFlag.EPHEMERAL, hikari.messages.MessageFlag.SUPPRESS_NOTIFICATIONS and hikari.messages.MessageFlag.SUPPRESS_EMBEDS.

TYPE: Union[int, MessageFlag, UndefinedType] DEFAULT: UNDEFINED

tts

If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system.

TYPE: UndefinedOr[bool] DEFAULT: UNDEFINED

mentions_everyone

If provided, whether the message should parse @everyone/@here mentions.

TYPE: UndefinedOr[bool] DEFAULT: UNDEFINED

user_mentions

If provided, and True, all user mentions will be detected. If provided, and False, all user mentions will be ignored if appearing in the message body. Alternatively this may be a collection of hikari.snowflakes.Snowflake, or hikari.users.PartialUser derivatives to enforce mentioning specific users.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]] DEFAULT: UNDEFINED

role_mentions

If provided, and True, all role mentions will be detected. If provided, and False, all role mentions will be ignored if appearing in the message body. Alternatively this may be a collection of hikari.snowflakes.Snowflake, or hikari.guilds.PartialRole derivatives to enforce mentioning specific roles.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]] DEFAULT: UNDEFINED

RAISES DESCRIPTION
ValueError

If more than 100 unique objects/entities are passed for role_mentions or user_mentions.

TypeError

If both embed and embeds are specified.

BadRequestError

This may be raised in several discrete situations, such as messages being empty with no embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; invalid image URLs in embeds.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

NotFoundError

If the interaction is not found or if the interaction's initial response has already been created.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

delete_initial_response async #

delete_initial_response() -> None

Delete the initial response of this interaction.

RAISES DESCRIPTION
UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

NotFoundError

If the interaction or response is not found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

edit_initial_response async #

edit_initial_response(content: UndefinedNoneOr[Any] = undefined.UNDEFINED, *, attachment: UndefinedNoneOr[Union[Resourceish, Attachment]] = undefined.UNDEFINED, attachments: UndefinedNoneOr[Sequence[Union[Resourceish, Attachment]]] = undefined.UNDEFINED, component: UndefinedNoneOr[ComponentBuilder] = undefined.UNDEFINED, components: UndefinedNoneOr[Sequence[ComponentBuilder]] = undefined.UNDEFINED, embed: UndefinedNoneOr[Embed] = undefined.UNDEFINED, embeds: UndefinedNoneOr[Sequence[Embed]] = undefined.UNDEFINED, mentions_everyone: UndefinedOr[bool] = undefined.UNDEFINED, user_mentions: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]] = undefined.UNDEFINED, role_mentions: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]] = undefined.UNDEFINED) -> Message

Edit the initial response of this command interaction.

Note

Mentioning everyone, roles, or users in message edits currently will not send a push notification showing a new mention to people on Discord. It will still highlight in their chat as if they were mentioned, however.

Warning

If you specify a text content, mentions_everyone, mentions_reply, user_mentions, and role_mentions will default to False as the message will be re-parsed for mentions. This will also occur if only one of the four are specified

This is a limitation of Discord's design. If in doubt, specify all four of them each time.

PARAMETER DESCRIPTION
content

If provided, the message contents. If hikari.undefined.UNDEFINED, then nothing will be sent in the content. Any other value here will be cast to a str.

If this is a hikari.embeds.Embed and neither the embed or embeds kwargs are provided or if this is a hikari.files.Resourceish and neither the attachment or attachments kwargs are provided, the values will be overwritten. This allows for simpler syntax when sending an embed or an attachment alone.

Likewise, if this is a hikari.files.Resource, then the content is instead treated as an attachment if no attachment and no attachments kwargs are provided.

TYPE: UndefinedNoneOr[Any] DEFAULT: UNDEFINED

attachment

If provided, the attachment to set on the message. If hikari.undefined.UNDEFINED, the previous attachment, if present, is not changed. If this is None, then the attachment is removed, if present. Otherwise, the new attachment that was provided will be attached.

TYPE: UndefinedNoneOr[Union[Resourceish, Attachment]] DEFAULT: UNDEFINED

attachments

If provided, the attachments to set on the message. If hikari.undefined.UNDEFINED, the previous attachments, if present, are not changed. If this is None, then the attachments is removed, if present. Otherwise, the new attachments that were provided will be attached.

TYPE: UndefinedNoneOr[Sequence[Union[Resourceish, Attachment]]] DEFAULT: UNDEFINED

component

If provided, builder object of the component to set for this message. This component will replace any previously set components and passing None will remove all components.

TYPE: UndefinedNoneOr[ComponentBuilder] DEFAULT: UNDEFINED

components

If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing None or an empty sequence will remove all components.

TYPE: UndefinedNoneOr[Sequence[ComponentBuilder]] DEFAULT: UNDEFINED

embed

If provided, the embed to set on the message. If hikari.undefined.UNDEFINED, the previous embed(s) are not changed. If this is None then any present embeds are removed. Otherwise, the new embed that was provided will be used as the replacement.

TYPE: UndefinedNoneOr[Embed] DEFAULT: UNDEFINED

embeds

If provided, the embeds to set on the message. If hikari.undefined.UNDEFINED, the previous embed(s) are not changed. If this is None then any present embeds are removed. Otherwise, the new embeds that were provided will be used as the replacement.

TYPE: UndefinedNoneOr[Sequence[Embed]] DEFAULT: UNDEFINED

mentions_everyone

If provided, whether the message should parse @everyone/@here mentions.

TYPE: UndefinedOr[bool] DEFAULT: UNDEFINED

user_mentions

If provided, and True, all user mentions will be detected. If provided, and False, all user mentions will be ignored if appearing in the message body. Alternatively this may be a collection of hikari.snowflakes.Snowflake, or hikari.users.PartialUser derivatives to enforce mentioning specific users.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]] DEFAULT: UNDEFINED

role_mentions

If provided, and True, all role mentions will be detected. If provided, and False, all role mentions will be ignored if appearing in the message body. Alternatively this may be a collection of hikari.snowflakes.Snowflake, or hikari.guilds.PartialRole derivatives to enforce mentioning specific roles.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]] DEFAULT: UNDEFINED

RETURNS DESCRIPTION
Message

The edited message.

RAISES DESCRIPTION
ValueError

If more than 100 unique objects/entities are passed for role_mentions or user_mentions.

TypeError

If both embed and embeds are specified.

BadRequestError

This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

NotFoundError

If the interaction or the message are not found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

fetch_initial_response async #

fetch_initial_response() -> Message

Fetch the initial response of this interaction.

RETURNS DESCRIPTION
Message

Message object of the initial response.

RAISES DESCRIPTION
ForbiddenError

If you cannot access the target interaction.

NotFoundError

If the initial response isn't 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 max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

ModalResponseMixin #

Bases: PartialInteraction

Mixin' class for all interaction types which can be responded to with a modal.

build_modal_response #

build_modal_response(title: str, custom_id: str) -> InteractionModalBuilder

Create a builder for a modal interaction response.

PARAMETER DESCRIPTION
title

The title that will show up in the modal.

TYPE: str

custom_id

Developer set custom ID used for identifying interactions with this modal.

TYPE: str

RETURNS DESCRIPTION
InteractionModalBuilder

The interaction modal response builder object.

create_modal_response async #

create_modal_response(title: str, custom_id: str, component: UndefinedOr[ComponentBuilder] = undefined.UNDEFINED, components: UndefinedOr[Sequence[ComponentBuilder]] = undefined.UNDEFINED) -> None

Create a response by sending a modal.

PARAMETER DESCRIPTION
title

The title that will show up in the modal.

TYPE: str

custom_id

Developer set custom ID used for identifying interactions with this modal.

TYPE: str

component

A component builder to send in this modal.

TYPE: UndefinedOr[ComponentBuilder] DEFAULT: UNDEFINED

components

A sequence of component builders to send in this modal.

TYPE: UndefinedOr[Sequence[ComponentBuilder]] DEFAULT: UNDEFINED

RAISES DESCRIPTION
ValueError

If both component and components are specified or if none are specified.

PartialInteraction #

Bases: Unique, ExecutableWebhook

The base model for all interaction models.

app class-attribute instance-attribute #

app: RESTAware = field(repr=False, eq=False, metadata={SKIP_DEEP_COPY: True})

Client application that models may use for procedures.

application_id class-attribute instance-attribute #

application_id: Snowflake = field(eq=False, repr=False)

ID of the application this interaction belongs to.

id class-attribute instance-attribute #

id: Snowflake = field(hash=True, repr=True)

ID of this entity.

token class-attribute instance-attribute #

token: str = field(eq=False, repr=False)

The interaction's token.

type class-attribute instance-attribute #

type: Union[InteractionType, int] = field(eq=False, repr=True)

The type of interaction this is.

version class-attribute instance-attribute #

version: int = field(eq=False, repr=True)

Version of the interaction system this interaction is under.

webhook_id property #

webhook_id: Snowflake

ID used to execute this entity as a webhook.

PremiumResponseMixin #

Bases: PartialInteraction

Mixin' class for all interaction types which can be responded to with a premium upsell.

create_premium_required_response async #

create_premium_required_response() -> None

Create a response by sending a premium upsell.

RAISES DESCRIPTION
ForbiddenError

If you cannot access the target interaction.

NotFoundError

If the initial response isn't 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 max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

ResolvedOptionData #

Represents the resolved objects of entities referenced in a command's options.

attachments class-attribute instance-attribute #

attachments: Mapping[Snowflake, Attachment] = field(repr=False)

Mapping of snowflake IDs to the attachment objects.

channels class-attribute instance-attribute #

channels: Mapping[Snowflake, InteractionChannel] = field(repr=False)

Mapping of snowflake IDs to the resolved option partial channel objects.

members class-attribute instance-attribute #

members: Mapping[Snowflake, InteractionMember] = field(repr=False)

Mapping of snowflake IDs to the resolved option member objects.

messages class-attribute instance-attribute #

messages: Mapping[Snowflake, Message] = field(repr=False)

Mapping of snowflake IDs to the resolved option partial message objects.

roles class-attribute instance-attribute #

roles: Mapping[Snowflake, Role] = field(repr=False)

Mapping of snowflake IDs to the resolved option role objects.

users class-attribute instance-attribute #

users: Mapping[Snowflake, User] = field(repr=False)

Mapping of snowflake IDs to the resolved option user objects.

ResponseType #

Bases: int, Enum

The type of an interaction response.

AUTOCOMPLETE class-attribute instance-attribute #

AUTOCOMPLETE = 8

Respond to an autocomplete interaction with suggested choices.

This is valid for the following interaction types:

DEFERRED_MESSAGE_CREATE class-attribute instance-attribute #

DEFERRED_MESSAGE_CREATE = 5

Acknowledge an interaction with the intention to edit in a message response later.

The user will see a loading state when this type is used until this interaction expires or a message response is edited in over REST.

This is valid for the following interaction types:

DEFERRED_MESSAGE_UPDATE class-attribute instance-attribute #

DEFERRED_MESSAGE_UPDATE = 6

Acknowledge an interaction with the intention to edit its message later.

This is valid for the following interaction types:

MESSAGE_CREATE class-attribute instance-attribute #

MESSAGE_CREATE = 4

MESSAGE_UPDATE class-attribute instance-attribute #

MESSAGE_UPDATE = 7

An immediate interaction response with instructions on how to update its message.

This is valid for the following interaction types:

MODAL class-attribute instance-attribute #

MODAL = 9

An immediate interaction response with instructions to display a modal.

This is valid for the following interaction types:

PREMIUM_REQUIRED class-attribute instance-attribute #

PREMIUM_REQUIRED = 10

An immediate interaction response with a premium upsell button Only available for apps with monetization enabled.

This is valid for the following interaction types:

  • InteractionType.APPLICATION_COMMAND
  • InteractionType.MESSAGE_COMPONENT
  • InteractionType.MODAL_SUBMIT