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([DEFERRED_MESSAGE_CREATE, DEFERRED_MESSAGE_UPDATE])
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
#
MESSAGE_RESPONSE_TYPES: Final[AbstractSet[MessageResponseTypesT]] = frozenset([MESSAGE_CREATE, MESSAGE_UPDATE])
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: |
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: |
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.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 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.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: |
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
#
Client application that models may use for procedures.
application_id class-attribute
instance-attribute
#
ID of the application this interaction belongs to.
id class-attribute
instance-attribute
#
ID of this entity.
token class-attribute
instance-attribute
#
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 of the interaction system this interaction is under.
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 |
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
#
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
#
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:
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:
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