hikari.interactions.base_interactions#
Base classes and enums inherited and used throughout the interactions flow.
Module Contents#
- class hikari.interactions.base_interactions.InteractionType[source]#
Bases:
int
,hikari.internal.enums.Enum
The type of an interaction.
- class hikari.interactions.base_interactions.ResponseType[source]#
Bases:
int
,hikari.internal.enums.Enum
The type of an interaction response.
- DEFERRED_MESSAGE_CREATE = 5[source]#
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 = 6[source]#
Acknowledge an interaction with the intention to edit its message later.
This is valid for the following interaction types:
- MESSAGE_UPDATE = 7[source]#
An immediate interaction response with instructions on how to update its message.
This is valid for the following interaction types:
- AUTOCOMPLETE = 8[source]#
Respond to an autocomplete interaction with suggested choices.
This is valid for the following interaction types:
- hikari.interactions.base_interactions.MESSAGE_RESPONSE_TYPES: Final[AbstractSet[MessageResponseTypesT]][source]#
Set of the response types which are valid for message responses.
This includes the following:
- hikari.interactions.base_interactions.MessageResponseTypesT[source]#
Type-hint of the response types which are valid for message responses.
The following are valid for this:
- hikari.interactions.base_interactions.DEFERRED_RESPONSE_TYPES: Final[AbstractSet[DeferredResponseTypesT]][source]#
Set of the response types which are valid for deferred messages responses.
This includes the following:
- hikari.interactions.base_interactions.DeferredResponseTypesT[source]#
Type-hint of the response types which are valid for deferred messages responses.
The following are valid for this:
- class hikari.interactions.base_interactions.PartialInteraction[source]#
Bases:
hikari.snowflakes.Unique
,hikari.webhooks.ExecutableWebhook
The base model for all interaction models.
- app: hikari.traits.RESTAware[source]#
Client application that models may use for procedures.
- application_id: hikari.snowflakes.Snowflake[source]#
ID of the application this interaction belongs to.
- type: Union[InteractionType, int][source]#
The type of interaction this is.
- class hikari.interactions.base_interactions.MessageResponseMixin[source]#
Bases:
PartialInteraction
,Generic
[_CommandResponseTypesT
]Mixin’ class for all interaction types which can be responded to with a message.
- async fetch_initial_response()[source]#
Fetch the initial response of this interaction.
- Returns
hikari.messages.Message
Message object of the initial response.
- Raises
hikari.errors.ForbiddenError
If you cannot access the target interaction.
hikari.errors.NotFoundError
If the initial response isn’t 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.RateLimitedError
Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
hikari.errors.InternalServerError
If an internal error occurs on Discord while handling the request.
- async create_initial_response(response_type, content=undefined.UNDEFINED, *, flags=undefined.UNDEFINED, tts=undefined.UNDEFINED, attachment=undefined.UNDEFINED, attachments=undefined.UNDEFINED, component=undefined.UNDEFINED, components=undefined.UNDEFINED, embed=undefined.UNDEFINED, embeds=undefined.UNDEFINED, mentions_everyone=undefined.UNDEFINED, user_mentions=undefined.UNDEFINED, role_mentions=undefined.UNDEFINED)[source]#
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.- Parameters
- response_type
typing.Union
[int
,CommandResponseTypesT
] The type of interaction response this is.
- response_type
- Other Parameters
- content
hikari.undefined.UndefinedOr
[typing.Any
] 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 astr
.If this is a
hikari.embeds.Embed
and noembed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.- attachment
hikari.undefined.UndefinedNoneOr
[typing.Union
[hikari.files.Resourceish
,hikari.messages.Attachment
]] If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.
- attachments
hikari.undefined.UndefinedNoneOr
[typing.Sequence
[typing.Union
[hikari.files.Resourceish
,hikari.messages.Attachment
]]] If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
- component
hikari.undefined.UndefinedNoneOr
[hikari.api.special_endpoints.ComponentBuilder
] If provided, builder object of the component to include in this message.
- components
hikari.undefined.UndefinedNoneOr
[typing.Sequence
[hikari.api.special_endpoints.ComponentBuilder
]] If provided, a sequence of the component builder objects to include in this message.
- embed
hikari.undefined.UndefinedNoneOr
[hikari.embeds.Embed
] If provided, the message embed.
- embeds
hikari.undefined.UndefinedNoneOr
[typing.Sequence
[hikari.embeds.Embed
]] If provided, the message embeds.
- flags
typing.Union
[int
,hikari.messages.MessageFlag
,hikari.undefined.UndefinedType
] If provided, the message flags this response should have.
As of writing the only message flag which can be set here is
hikari.messages.MessageFlag.EPHEMERAL
.- tts
hikari.undefined.UndefinedOr
[bool] If provided, whether the message will be read out by a screen reader using Discord’s TTS (text-to-speech) system.
- mentions_everyone
hikari.undefined.UndefinedOr
[bool] If provided, whether the message should parse @everyone/@here mentions.
- user_mentions
hikari.undefined.UndefinedOr
[typing.Union
[hikari.snowflakes.SnowflakeishSequence
[hikari.users.PartialUser
], bool]] If provided, and
True
, all user mentions will be detected. If provided, andFalse
, all user mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.users.PartialUser
derivatives to enforce mentioning specific users.- role_mentions
hikari.undefined.UndefinedOr
[typing.Union
[hikari.snowflakes.SnowflakeishSequence
[hikari.guilds.PartialRole
], bool]] If provided, and
True
, all role mentions will be detected. If provided, andFalse
, all role mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.guilds.PartialRole
derivatives to enforce mentioning specific roles.
- content
- Raises
ValueError
If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.TypeError
If both
embed
andembeds
are specified.hikari.errors.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.
hikari.errors.UnauthorizedError
If you are unauthorized to make the request (invalid/missing token).
hikari.errors.NotFoundError
If the interaction is not found or if the interaction’s initial response has already been created.
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.RateLimitedError
Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
hikari.errors.InternalServerError
If an internal error occurs on Discord while handling the request.
- async edit_initial_response(content=undefined.UNDEFINED, *, attachment=undefined.UNDEFINED, attachments=undefined.UNDEFINED, component=undefined.UNDEFINED, components=undefined.UNDEFINED, embed=undefined.UNDEFINED, embeds=undefined.UNDEFINED, mentions_everyone=undefined.UNDEFINED, user_mentions=undefined.UNDEFINED, role_mentions=undefined.UNDEFINED)[source]#
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
, androle_mentions
will default toFalse
as the message will be re-parsed for mentions. This will also occur if only one of the four are specifiedThis is a limitation of Discord’s design. If in doubt, specify all four of them each time.
- Other Parameters
- content
hikari.undefined.UndefinedNoneOr
[typing.Any
] 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 astr
.If this is a
hikari.embeds.Embed
and neither theembed
orembeds
kwargs are provided or if this is ahikari.files.Resourceish
and neither theattachment
orattachments
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 noattachment
and noattachments
kwargs are provided.- attachment
hikari.undefined.UndefinedNoneOr
[typing.Union
[hikari.files.Resourceish
,hikari.messages.Attachment
]] If provided, the attachment to set on the message. If
hikari.undefined.UNDEFINED
, the previous attachment, if present, is not changed. If this isNone
, then the attachment is removed, if present. Otherwise, the new attachment that was provided will be attached.- attachments
hikari.undefined.UndefinedNoneOr
[typing.Sequence
[typing.Union
[hikari.files.Resourceish
,hikari.messages.Attachment
]]] If provided, the attachments to set on the message. If
hikari.undefined.UNDEFINED
, the previous attachments, if present, are not changed. If this isNone
, then the attachments is removed, if present. Otherwise, the new attachments that were provided will be attached.- component
hikari.undefined.UndefinedNoneOr
[hikari.api.special_endpoints.ComponentBuilder
] 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.- components
hikari.undefined.UndefinedNoneOr
[typing.Sequence
[hikari.api.special_endpoints.ComponentBuilder
]] 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.- embed
hikari.undefined.UndefinedNoneOr
[hikari.embeds.Embed
] If provided, the embed to set on the message. If
hikari.undefined.UNDEFINED
, the previous embed(s) are not changed. If this isNone
then any present embeds are removed. Otherwise, the new embed that was provided will be used as the replacement.- embeds
hikari.undefined.UndefinedNoneOr
[typing.Sequence
[hikari.embeds.Embed
]] If provided, the embeds to set on the message. If
hikari.undefined.UNDEFINED
, the previous embed(s) are not changed. If this isNone
then any present embeds are removed. Otherwise, the new embeds that were provided will be used as the replacement.- mentions_everyone
hikari.undefined.UndefinedOr
[bool] If provided, whether the message should parse @everyone/@here mentions.
- user_mentions
hikari.undefined.UndefinedOr
[typing.Union
[hikari.snowflakes.SnowflakeishSequence
[hikari.users.PartialUser
], bool]] If provided, and
True
, all user mentions will be detected. If provided, andFalse
, all user mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.users.PartialUser
derivatives to enforce mentioning specific users.- role_mentions
hikari.undefined.UndefinedOr
[typing.Union
[hikari.snowflakes.SnowflakeishSequence
[hikari.guilds.PartialRole
], bool]] If provided, and
True
, all role mentions will be detected. If provided, andFalse
, all role mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.guilds.PartialRole
derivatives to enforce mentioning specific roles.
- content
- Returns
hikari.messages.Message
The edited message.
- Raises
ValueError
If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.TypeError
If both
embed
andembeds
are specified.hikari.errors.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.
hikari.errors.UnauthorizedError
If you are unauthorized to make the request (invalid/missing token).
hikari.errors.NotFoundError
If the interaction or the message are 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.RateLimitedError
Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
hikari.errors.InternalServerError
If an internal error occurs on Discord while handling the request.
- async delete_initial_response()[source]#
Delete the initial response of this interaction.
- Raises
hikari.errors.UnauthorizedError
If you are unauthorized to make the request (invalid/missing token).
hikari.errors.NotFoundError
If the interaction or response 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.RateLimitedError
Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
hikari.errors.InternalServerError
If an internal error occurs on Discord while handling the request.
- class hikari.interactions.base_interactions.ModalResponseMixin[source]#
Bases:
PartialInteraction
Mixin’ class for all interaction types which can be responded to with a modal.
- async create_modal_response(title, custom_id, component=undefined.UNDEFINED, components=undefined.UNDEFINED)[source]#
Create a response by sending a modal.
- Parameters
- Other Parameters
- component
hikari.undefined.UndefinedOr
[typing.Sequence
[special_endpoints.ComponentBuilder
]] A component builders to send in this modal.
- components
hikari.undefined.UndefinedOr
[typing.Sequence
[special_endpoints.ComponentBuilder
]] A sequence of component builders to send in this modal.
- component
- Raises
ValueError
If both
component
andcomponents
are specified or if none are specified.
- build_modal_response(title, custom_id)[source]#
Create a builder for a modal interaction response.
- Parameters
- title
builtins.str
The title that will show up in the modal.
- custom_id
builtins.str
Developer set custom ID used for identifying interactions with this modal.
- title
- Returns
hikari.api.special_endpoints.InteractionModalBuilder
The interaction modal response builder object.
- class hikari.interactions.base_interactions.InteractionMember[source]#
Bases:
hikari.guilds.Member
Model of the member who triggered an interaction.
Unlike
hikari.guilds.Member
, this object comes with an extraInteractionMember.permissions
field.- permissions: hikari.permissions.Permissions[source]#
Permissions the member has in the current channel.