hikari.interactions.base_interactions#
Base classes and enums inherited and used throughout the interactions flow.
DEFERRED_RESPONSE_TYPES module-attribute #
DEFERRED_RESPONSE_TYPES: Final[
AbstractSet[DeferredResponseTypesT]
] = frozenset(
[
ResponseType.DEFERRED_MESSAGE_CREATE,
ResponseType.DEFERRED_MESSAGE_UPDATE,
]
)
Set of the response types which are valid for deferred messages responses.
This includes the following:
DeferredResponseTypesT module-attribute #
DeferredResponseTypesT = typing.Literal[
ResponseType.DEFERRED_MESSAGE_CREATE,
5,
ResponseType.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 #
MESSAGE_RESPONSE_TYPES: Final[
AbstractSet[MessageResponseTypesT]
] = frozenset(
[
ResponseType.MESSAGE_CREATE,
ResponseType.MESSAGE_UPDATE,
]
)
Set of the response types which are valid for message responses.
This includes the following:
MessageResponseTypesT module-attribute #
MessageResponseTypesT = typing.Literal[
ResponseType.MESSAGE_CREATE,
4,
ResponseType.MESSAGE_UPDATE,
7,
]
Type-hint of the response types which are valid for message responses.
The following are valid for this:
InteractionCallback #
Bases: Unique
An interaction callback object.
activity_instance_id class-attribute instance-attribute #
activity_instance_id: UndefinedOr[str] = attrs.field(
hash=False, repr=True
)
The instance ID of the activity if one was launched or joined.
id class-attribute instance-attribute #
ID of this entity.
response_message_ephemeral class-attribute instance-attribute #
The ID of the message that was created by the interaction.
Will always be False if no message was created.
response_message_id class-attribute instance-attribute #
response_message_id: UndefinedOr[Snowflake] = attrs.field(
hash=False, repr=True
)
The ID of the message that was created by the interaction.
response_message_loading class-attribute instance-attribute #
Whether the created message is in a loading state.
Will always be False if no message was created.
type class-attribute instance-attribute #
type: InteractionType = attrs.field(hash=True, repr=True)
The type of the interaction.
InteractionCallbackActivityInstance #
InteractionCallbackResource #
An interaction callback resources.
activity_instance class-attribute instance-attribute #
activity_instance: UndefinedOr[
InteractionCallbackActivityInstance
] = attrs.field()
The activity launched by this interaction.
Will only be present if type is LAUNCH_ACTIVITY.
message class-attribute instance-attribute #
message: UndefinedOr[Message] = attrs.field()
The message created by the interaction.
Will only be present if type is CHANNEL_MESSAGE_WITH_SOURCE or UPDATE_MESSAGE.
type class-attribute instance-attribute #
type: ResponseType = attrs.field()
The type of the interaction response.
InteractionCallbackResponse #
The response to an interaction callback.
interaction class-attribute instance-attribute #
interaction: InteractionCallback = attrs.field()
The interaction object associated with the interaction response.
resource class-attribute instance-attribute #
resource: UndefinedOr[InteractionCallbackResource] = (
attrs.field()
)
The resource that was created by the interaction response, if any.
InteractionChannel #
Bases: PartialChannel
Represents partial channels returned as resolved entities on interactions.
parent_id class-attribute instance-attribute #
The parent ID of the channel.
This will be None for DM channels and guild channels that have no parent.
permissions class-attribute instance-attribute #
permissions: Permissions = attrs.field(
eq=False, hash=False, repr=True
)
Permissions the command's executor has in this channel.
thread_metadata class-attribute instance-attribute #
thread_metadata: ThreadMetadata | None = attrs.field(
eq=False, hash=False, repr=False
)
The thread metadata, if the channel is a thread.
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 = attrs.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,
*,
flags: int | MessageFlag | UndefinedType = UNDEFINED,
tts: UndefinedOr[bool] = UNDEFINED,
attachment: UndefinedNoneOr[Resourceish] = UNDEFINED,
attachments: UndefinedNoneOr[
Sequence[Resourceish]
] = UNDEFINED,
component: UndefinedNoneOr[
ComponentBuilder
] = UNDEFINED,
components: UndefinedNoneOr[
Sequence[ComponentBuilder]
] = UNDEFINED,
embed: UndefinedNoneOr[Embed] = UNDEFINED,
embeds: UndefinedNoneOr[Sequence[Embed]] = UNDEFINED,
poll: UndefinedOr[PollBuilder] = UNDEFINED,
mentions_everyone: UndefinedOr[bool] = UNDEFINED,
user_mentions: UndefinedOr[
SnowflakeishSequence[PartialUser] | bool
] = UNDEFINED,
role_mentions: UndefinedOr[
SnowflakeishSequence[PartialRole] | bool
] = UNDEFINED,
) -> InteractionCallbackResponse
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: |
content | If provided, the message contents. If If this is a TYPE: |
attachment | If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL. TYPE: |
attachments | If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs. TYPE: |
component | If provided, builder object of the component to include in this message. TYPE: |
components | If provided, a sequence of the component builder objects to include in this message. TYPE: |
embed | If provided, the message embed. TYPE: |
embeds | If provided, the message embeds. TYPE: |
poll | If provided, the poll to set on the message. TYPE: |
flags | If provided, the message flags this response should have. As of writing the only message flags which can be set here are TYPE: |
tts | If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system. TYPE: |
mentions_everyone | If provided, whether the message should parse @everyone/@here mentions. TYPE: |
user_mentions | If provided, and TYPE: |
role_mentions | If provided, and TYPE: |
| RAISES | DESCRIPTION |
|---|---|
ValueError | If more than 100 unique objects/entities are passed for |
TypeError | If both |
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 |
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 |
InternalServerError | If an internal error occurs on Discord while handling the request. |
edit_initial_response async #
edit_initial_response(
content: UndefinedNoneOr[Any] = UNDEFINED,
*,
attachment: UndefinedNoneOr[
Resourceish | Attachment
] = UNDEFINED,
attachments: UndefinedNoneOr[
Sequence[Resourceish | Attachment]
] = UNDEFINED,
component: UndefinedNoneOr[
ComponentBuilder
] = UNDEFINED,
components: UndefinedNoneOr[
Sequence[ComponentBuilder]
] = UNDEFINED,
embed: UndefinedNoneOr[Embed] = UNDEFINED,
embeds: UndefinedNoneOr[Sequence[Embed]] = UNDEFINED,
mentions_everyone: UndefinedOr[bool] = UNDEFINED,
user_mentions: UndefinedOr[
SnowflakeishSequence[PartialUser] | bool
] = UNDEFINED,
role_mentions: UndefinedOr[
SnowflakeishSequence[PartialRole] | bool
] = 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 If this is a Likewise, if this is a TYPE: |
attachment | If provided, the attachment to set on the message. If TYPE: |
attachments | If provided, the attachments to set on the message. If TYPE: |
component | If provided, builder object of the component to set for this message. This component will replace any previously set components and passing TYPE: |
components | If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing TYPE: |
embed | If provided, the embed to set on the message. If TYPE: |
embeds | If provided, the embeds to set on the message. If TYPE: |
mentions_everyone | If provided, whether the message should parse @everyone/@here mentions. TYPE: |
user_mentions | If provided, and TYPE: |
role_mentions | If provided, and TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Message | The edited message. |
| RAISES | DESCRIPTION |
|---|---|
ValueError | If more than 100 unique objects/entities are passed for |
TypeError | If both |
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 |
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 |
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: |
custom_id | Developer set custom ID used for identifying interactions with this modal. TYPE: |
| 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,
components: UndefinedOr[
Sequence[ComponentBuilder]
] = UNDEFINED,
) -> InteractionCallbackResponse
Create a response by sending a modal.
| PARAMETER | DESCRIPTION |
|---|---|
title | The title that will show up in the modal. TYPE: |
custom_id | Developer set custom ID used for identifying interactions with this modal. TYPE: |
component | A component builder to send in this modal. TYPE: |
components | A sequence of component builders to send in this modal. TYPE: |
| RAISES | DESCRIPTION |
|---|---|
ValueError | If both |
PartialInteraction #
Bases: Unique, ExecutableWebhook
The base model for all interaction models.
app class-attribute instance-attribute #
app: RESTAware = attrs.field(
repr=False,
eq=False,
metadata={attrs_extensions.SKIP_DEEP_COPY: True},
)
Client application that models may use for procedures.
app_permissions class-attribute instance-attribute #
app_permissions: Permissions | None = attrs.field(
eq=False, hash=False, repr=False
)
Permissions the bot has in this interaction's channel if it's in a guild.
application_id class-attribute instance-attribute #
ID of the application this interaction belongs to.
attachment_size_limit class-attribute instance-attribute #
The size limit of the attachments that can be uploaded.
authorizing_integration_owners class-attribute instance-attribute #
authorizing_integration_owners: Mapping[
ApplicationIntegrationType, Snowflake
] = attrs.field(eq=False, repr=True)
A mapping of the [applications.ApplicationIntegrationType] to the related guild or user ID.
channel class-attribute instance-attribute #
channel: InteractionChannel = attrs.field(
eq=False, repr=False
)
The channel this interaction was triggered in.
context class-attribute instance-attribute #
context: ApplicationContextType = attrs.field(
eq=False, repr=True
)
The interaction context.
entitlements class-attribute instance-attribute #
entitlements: Sequence[Entitlement] = attrs.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 component interaction was triggered in.
This will be None for component interactions triggered in DMs.
Note
This value can usually only be changed if [COMMUNITY] is in hikari.guilds.Guild.features for the guild and will otherwise default to en-US.
id class-attribute instance-attribute #
ID of this entity.
locale class-attribute instance-attribute #
The selected language of the user who triggered this modal interaction.
member class-attribute instance-attribute #
member: InteractionMember | None = attrs.field(
eq=False, hash=False, repr=True
)
The member who triggered this interaction.
This will be None for interactions triggered in DMs.
Note
This member object comes with the extra field permissions which contains the member's permissions in the current channel.
token class-attribute instance-attribute #
The interaction's token.
type class-attribute instance-attribute #
type: InteractionType = attrs.field(eq=False, repr=True)
The type of interaction this is.
user class-attribute instance-attribute #
The user who triggered this interaction.
version class-attribute instance-attribute #
Version of the interaction system this interaction is under.
fetch_guild async #
fetch_guild() -> RESTGuild | None
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_guild #
get_guild() -> GatewayGuild | None
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 |
PartialInteractionMetadata #
Metadata about the interaction, including the source of the interaction and relevant server and user IDs.
authorizing_integration_owners class-attribute instance-attribute #
authorizing_integration_owners: Mapping[
ApplicationIntegrationType, Snowflake
] = attrs.field(eq=False, repr=True)
A mapping of the [applications.ApplicationIntegrationType] to the related guild or user ID.
interaction_id class-attribute instance-attribute #
The ID for this message interaction.
original_response_message_id class-attribute instance-attribute #
The ID of the original response message.
type class-attribute instance-attribute #
type: InteractionType | int = attrs.field(
eq=False, repr=True
)
The type of this message interaction.
ResolvedOptionData #
Represents the resolved objects of entities referenced in a command's options.
attachments class-attribute instance-attribute #
Mapping of snowflake IDs to the attachment objects.
channels class-attribute instance-attribute #
channels: Mapping[Snowflake, InteractionChannel] = (
attrs.field(repr=False)
)
Mapping of snowflake IDs to the resolved option partial channel objects.
members class-attribute instance-attribute #
members: Mapping[Snowflake, InteractionMember] = (
attrs.field(repr=False)
)
Mapping of snowflake IDs to the resolved option member objects.
messages class-attribute instance-attribute #
Mapping of snowflake IDs to the resolved option partial message objects.
roles class-attribute instance-attribute #
Mapping of snowflake IDs to the resolved option role 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:
LAUNCH_ACTIVITY class-attribute instance-attribute #
LAUNCH_ACTIVITY = 12
An immediate interaction response launching the activity associated with the application.
This response type is only available for applications with activities enabled.
MESSAGE_CREATE class-attribute instance-attribute #
MESSAGE_CREATE = 4
An immediate message response to an interaction.
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: