hikari.interactions.component_interactions
#
Models and enums used for Discord's Components interaction flow.
COMPONENT_RESPONSE_TYPES module-attribute
#
COMPONENT_RESPONSE_TYPES: Final[AbstractSet[ComponentResponseTypesT]] = frozenset([*_DEFERRED_TYPES, *_IMMEDIATE_TYPES])
Set of the response types which are valid for a component interaction.
This includes:
ComponentResponseTypesT module-attribute
#
ComponentResponseTypesT = Union[_ImmediateTypesT, _DeferredTypesT]
Type-hint of the response types which are valid for a component interaction.
The following types are valid for this:
ComponentInteraction #
Bases: MessageResponseMixin[ComponentResponseTypesT]
, ModalResponseMixin
, PremiumResponseMixin
Represents a component 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 interaction was triggered in.
component_type class-attribute
instance-attribute
#
component_type: Union[ComponentType, int] = field(eq=False)
The type of component which triggers this interaction.
Note
This will never be hikari.components.ButtonStyle.LINK
as link buttons don't trigger interactions.
custom_id class-attribute
instance-attribute
#
Developer defined ID of the component which triggered this interaction.
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 interaction was triggered in.
This will be None
for component 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
.
locale class-attribute
instance-attribute
#
The selected language of the user who triggered this component interaction.
member class-attribute
instance-attribute
#
member: Optional[InteractionMember] = 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.
message class-attribute
instance-attribute
#
Object of the message the components for this interaction are attached to.
resolved class-attribute
instance-attribute
#
resolved: Optional[ResolvedOptionData] = field(eq=False, hash=False, repr=False)
Mappings of the objects resolved for the provided command options.
user class-attribute
instance-attribute
#
The user who triggered this interaction.
values class-attribute
instance-attribute
#
Sequence of the values which were selected for a select menu component.
build_deferred_response #
build_deferred_response(type_: _DeferredTypesT) -> InteractionDeferredBuilder
Get a deferred message response builder for use in the REST server flow.
Note
For interactions received over the gateway hikari.interactions.component_interactions.ComponentInteraction.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.
PARAMETER | DESCRIPTION |
---|---|
type_ | The type of deferred response this should be. This may be one of the following: TYPE: |
RETURNS | DESCRIPTION |
---|---|
InteractionDeferredBuilder | Deferred interaction message response builder object. |
build_response #
build_response(type_: _ImmediateTypesT) -> InteractionMessageBuilder
Get a message response builder for use in the REST server flow.
Note
For interactions received over the gateway hikari.interactions.component_interactions.ComponentInteraction.create_initial_response
should be used to set the interaction response message.
PARAMETER | DESCRIPTION |
---|---|
type_ | The type of immediate response this should be. This may be one of the following: TYPE: |
Examples:
async def handle_component_interaction(
interaction: ComponentInteraction,
) -> InteractionMessageBuilder:
return (
interaction.build_response(ResponseType.MESSAGE_UPDATE)
.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 channel this interaction occurred in.
RETURNS | DESCRIPTION |
---|---|
TextableChannel | The channel. This will be a derivative of |
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() -> Union[GuildTextChannel, GuildNewsChannel, None]
Get the guild channel this interaction occurred in.
Note
This will always return None
for interactions triggered in a DM channel.
RETURNS | DESCRIPTION |
---|---|
Union[GuildTextChannel, GuildNewsChannel, None] | The object of the guild channel that was found in the cache or |
get_guild #
get_guild() -> Optional[GatewayGuild]
Get the object of this interaction's guild from the cache.
RETURNS | DESCRIPTION |
---|---|
Optional[GatewayGuild] | The object of the guild if found, else |