Base classes and enums inherited and used throughout the interactions flow.
# -*- coding: utf-8 -*-
# cython: language_level=3
# Copyright (c) 2020 Nekokatt
# Copyright (c) 2021-present davfsa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Base classes and enums inherited and used throughout the interactions flow."""
from __future__ import annotations
__all__: typing.List[str] = [
"DEFERRED_RESPONSE_TYPES",
"DeferredResponseTypesT",
"InteractionMember",
"InteractionType",
"MessageResponseMixin",
"MESSAGE_RESPONSE_TYPES",
"MessageResponseTypesT",
"PartialInteraction",
"ResponseType",
]
import typing
import attr
from hikari import guilds
from hikari import snowflakes
from hikari import undefined
from hikari import webhooks
from hikari.internal import attr_extensions
from hikari.internal import enums
if typing.TYPE_CHECKING:
from hikari import embeds as embeds_
from hikari import files
from hikari import messages
from hikari import permissions as permissions_
from hikari import traits
from hikari import users
from hikari.api import special_endpoints
_CommandResponseTypesT = typing.TypeVar("_CommandResponseTypesT", bound=int)
@typing.final
class InteractionType(int, enums.Enum):
"""The type of an interaction."""
# PING isn't here as it should be handled as internal detail of the REST
# server rather than as a part of the public interface.
APPLICATION_COMMAND = 2
"""An interaction triggered by a user calling an application command."""
MESSAGE_COMPONENT = 3
"""An interaction triggered by a user calling a message component."""
AUTOCOMPLETE = 4
"""An interaction triggered by a user typing in a slash command option."""
@typing.final
class ResponseType(int, enums.Enum):
"""The type of an interaction response."""
# PONG isn't here as it should be handled as internal detail of the REST
# server rather than as a part of the public interface.
# Type 2 and 3 aren't included as they were deprecated/removed by Discord.
MESSAGE_CREATE = 4
"""An immediate message response to an interaction.
* `InteractionType.APPLICATION_COMMAND`
* `InteractionType.MESSAGE_COMPONENT`
"""
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:
* `InteractionType.APPLICATION_COMMAND`
* `InteractionType.MESSAGE_COMPONENT`
"""
DEFERRED_MESSAGE_UPDATE = 6
"""Acknowledge an interaction with the intention to edit its message later.
This is valid for the following interaction types:
* `InteractionType.MESSAGE_COMPONENT`
"""
MESSAGE_UPDATE = 7
"""An immediate interaction response with instructions on how to update its message.
This is valid for the following interaction types:
* `InteractionType.MESSAGE_COMPONENT`
"""
AUTOCOMPLETE = 8
"""Respond to an autocomplete interaction with suggested choices.
This is valid for the following interaction types:
* `InteractionType.AUTOCOMPLETE`
"""
MESSAGE_RESPONSE_TYPES: typing.Final[typing.AbstractSet[MessageResponseTypesT]] = frozenset(
[ResponseType.MESSAGE_CREATE, ResponseType.MESSAGE_UPDATE]
)
"""Set of the response types which are valid for message responses.
This includes the following:
* `ResponseType.MESSAGE_CREATE`
* `ResponseType.MESSAGE_UPDATE`
"""
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:
* `ResponseType.MESSAGE_CREATE`/`4`
* `ResponseType.MESSAGE_UPDATE`/`7`
"""
DEFERRED_RESPONSE_TYPES: typing.Final[typing.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:
* `ResponseType.DEFERRED_MESSAGE_CREATE`
* `ResponseType.DEFERRED_MESSAGE_UPDATE`
"""
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:
* `ResponseType.DEFERRED_MESSAGE_CREATE`/`5`
* `ResponseType.DEFERRED_MESSAGE_UPDATE`/`6`
"""
@attr_extensions.with_copy
@attr.define(hash=True, kw_only=True, weakref_slot=False)
class PartialInteraction(snowflakes.Unique, webhooks.ExecutableWebhook):
"""The base model for all interaction models."""
app: traits.RESTAware = attr.field(repr=False, eq=False, metadata={attr_extensions.SKIP_DEEP_COPY: True})
"""The client application that models may use for procedures."""
id: snowflakes.Snowflake = attr.field(hash=True, repr=True)
# <<inherited docstring from Unique>>.
application_id: snowflakes.Snowflake = attr.field(eq=False, repr=False)
"""ID of the application this interaction belongs to."""
type: typing.Union[InteractionType, int] = attr.field(eq=False, repr=True)
"""The type of interaction this is."""
token: str = attr.field(eq=False, repr=False)
"""The interaction's token."""
version: int = attr.field(eq=False, repr=True)
"""Version of the interaction system this interaction is under."""
@property
def webhook_id(self) -> snowflakes.Snowflake:
# <<inherited docstring from ExecutableWebhook>>.
return self.application_id
class MessageResponseMixin(PartialInteraction, typing.Generic[_CommandResponseTypesT]):
"""Mixin' class for all interaction types which can be responded to with a message."""
__slots__: typing.Sequence[str] = ()
async def fetch_initial_response(self) -> messages.Message:
"""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.
"""
return await self.app.rest.fetch_interaction_response(self.application_id, self.token)
async def create_initial_response(
self,
response_type: _CommandResponseTypesT,
content: undefined.UndefinedOr[typing.Any] = undefined.UNDEFINED,
*,
flags: typing.Union[int, messages.MessageFlag, undefined.UndefinedType] = undefined.UNDEFINED,
tts: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
attachment: undefined.UndefinedOr[files.Resourceish] = undefined.UNDEFINED,
attachments: undefined.UndefinedOr[typing.Sequence[files.Resourceish]] = undefined.UNDEFINED,
component: undefined.UndefinedOr[special_endpoints.ComponentBuilder] = undefined.UNDEFINED,
components: undefined.UndefinedOr[typing.Sequence[special_endpoints.ComponentBuilder]] = undefined.UNDEFINED,
embed: undefined.UndefinedOr[embeds_.Embed] = undefined.UNDEFINED,
embeds: undefined.UndefinedOr[typing.Sequence[embeds_.Embed]] = undefined.UNDEFINED,
mentions_everyone: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
user_mentions: undefined.UndefinedOr[
typing.Union[snowflakes.SnowflakeishSequence[users.PartialUser], bool]
] = undefined.UNDEFINED,
role_mentions: undefined.UndefinedOr[
typing.Union[snowflakes.SnowflakeishSequence[guilds.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.
Parameters
----------
response_type : typing.Union[builtins.int, CommandResponseTypesT]
The type of interaction response this is.
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 a
`builtins.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.
attachment : hikari.undefined.UndefinedOr[hikari.files.Resourceish],
If provided, the message attachment. This can be a resource,
or string of a path on your computer or a URL.
attachments : hikari.undefined.UndefinedOr[typing.Sequence[hikari.files.Resourceish]],
If provided, the message attachments. These can be resources, or
strings consisting of paths on your computer or URLs.
component : hikari.undefined.UndefinedOr[hikari.api.special_endpoints.ComponentBuilder]
If provided, builder object of the component to include in this message.
components : hikari.undefined.UndefinedOr[typing.Sequence[hikari.api.special_endpoints.ComponentBuilder]]
If provided, a sequence of the component builder objects to include
in this message.
embed : hikari.undefined.UndefinedOr[hikari.embeds.Embed]
If provided, the message embed.
embeds : hikari.undefined.UndefinedOr[typing.Sequence[hikari.embeds.Embed]]
If provided, the message embeds.
flags : typing.Union[builtins.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[builtins.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[builtins.bool]
If provided, whether the message should parse @everyone/@here
mentions.
user_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], builtins.bool]]
If provided, and `builtins.True`, all user mentions will be detected.
If provided, and `builtins.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.
role_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], builtins.bool]]
If provided, and `builtins.True`, all role mentions will be detected.
If provided, and `builtins.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.
Raises
------
builtins.ValueError
If more than 100 unique objects/entities are passed for
`role_mentions` or `user_mentions`.
builtins.TypeError
If both `embed` and `embeds` 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.
""" # noqa: E501 - Line too long
await self.app.rest.create_interaction_response(
self.id,
self.token,
response_type,
content,
tts=tts,
attachment=attachment,
attachments=attachments,
component=component,
components=components,
embed=embed,
embeds=embeds,
flags=flags,
mentions_everyone=mentions_everyone,
user_mentions=user_mentions,
role_mentions=role_mentions,
)
async def edit_initial_response(
self,
content: undefined.UndefinedNoneOr[typing.Any] = undefined.UNDEFINED,
*,
attachment: undefined.UndefinedOr[files.Resourceish] = undefined.UNDEFINED,
attachments: undefined.UndefinedOr[typing.Sequence[files.Resourceish]] = undefined.UNDEFINED,
component: undefined.UndefinedNoneOr[special_endpoints.ComponentBuilder] = undefined.UNDEFINED,
components: undefined.UndefinedNoneOr[
typing.Sequence[special_endpoints.ComponentBuilder]
] = undefined.UNDEFINED,
embed: undefined.UndefinedNoneOr[embeds_.Embed] = undefined.UNDEFINED,
embeds: undefined.UndefinedNoneOr[typing.Sequence[embeds_.Embed]] = undefined.UNDEFINED,
replace_attachments: bool = False,
mentions_everyone: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
user_mentions: undefined.UndefinedOr[
typing.Union[snowflakes.SnowflakeishSequence[users.PartialUser], bool]
] = undefined.UNDEFINED,
role_mentions: undefined.UndefinedOr[
typing.Union[snowflakes.SnowflakeishSequence[guilds.PartialRole], bool]
] = undefined.UNDEFINED,
) -> messages.Message:
"""Edit the initial response of this command interaction.
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 a
`builtins.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.
attachment : hikari.undefined.UndefinedOr[hikari.files.Resourceish]
If provided, the attachment to set on the message. If
`hikari.undefined.UNDEFINED`, the previous attachment, if
present, is not changed. If this is `builtins.None`, then the
attachment is removed, if present. Otherwise, the new attachment
that was provided will be attached.
attachments : hikari.undefined.UndefinedOr[typing.Sequence[hikari.files.Resourceish]]
If provided, the attachments to set on the message. If
`hikari.undefined.UNDEFINED`, the previous attachments, if
present, are not changed. If this is `builtins.None`, 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
`builtins.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 `builtins.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 is `builtins.None` 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 is `builtins.None` then any present embeds are removed.
Otherwise, the new embeds that were provided will be used as the
replacement.
replace_attachments: bool
Whether to replace the attachments with the provided ones. Defaults
to `builtins.False`.
Note this will also overwrite the embed attachments.
mentions_everyone : hikari.undefined.UndefinedOr[builtins.bool]
If provided, whether the message should parse @everyone/@here
mentions.
user_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], builtins.bool]]
If provided, and `builtins.True`, all user mentions will be detected.
If provided, and `builtins.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.
role_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], builtins.bool]]
If provided, and `builtins.True`, all role mentions will be detected.
If provided, and `builtins.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.
!!! 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 one of `mentions_everyone`, `user_mentions`, or
`role_mentions`, then all others will default to `builtins.False`,
even if they were enabled previously.
This is a limitation of Discord's design. If in doubt, specify all three of
them each time.
Returns
-------
hikari.messages.Message
The edited message.
Raises
------
builtins.ValueError
If more than 100 unique objects/entities are passed for
`role_mentions` or `user_mentions`.
builtins.TypeError
If both `embed` and `embeds` 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.
""" # noqa: E501 - Line too long
return await self.app.rest.edit_interaction_response(
self.application_id,
self.token,
content,
attachment=attachment,
attachments=attachments,
component=component,
components=components,
embed=embed,
embeds=embeds,
replace_attachments=replace_attachments,
mentions_everyone=mentions_everyone,
user_mentions=user_mentions,
role_mentions=role_mentions,
)
async def delete_initial_response(self) -> None:
"""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.
"""
await self.app.rest.delete_interaction_response(self.application_id, self.token)
@attr.define(hash=True, kw_only=True, weakref_slot=False)
class InteractionMember(guilds.Member):
"""Model of the member who triggered an interaction.
Unlike `hikari.guilds.Member`, this object comes with an extra
`InteractionMember.permissions` field.
"""
permissions: permissions_.Permissions = attr.field(eq=False, hash=False, repr=False)
"""Permissions the member has in the current channel."""
const DEFERRED_RESPONSE_TYPES : Final[AbstractSet[DeferredResponseTypesT]]
Set of the response types which are valid for deferred messages responses.
This includes the following:
var DeferredResponseTypesT
Type-hint of the response types which are valid for deferred messages responses.
The following are valid for this:
const MESSAGE_RESPONSE_TYPES : Final[AbstractSet[MessageResponseTypesT]]
Set of the response types which are valid for message responses.
This includes the following:
var MessageResponseTypesT
Type-hint of the response types which are valid for message responses.
The following are valid for this:
class InteractionMember (
*,
guild_id: snowflakes.Snowflake,
is_deaf: undefined.UndefinedOr[bool],
is_mute: undefined.UndefinedOr[bool],
is_pending: undefined.UndefinedOr[bool],
joined_at: datetime.datetime,
nickname: Optional[str],
premium_since: Optional[datetime.datetime],
raw_communication_disabled_until: Optional[datetime.datetime],
role_ids: Sequence[snowflakes.Snowflake],
user: users.User,
guild_avatar_hash: Optional[str],
permissions: permissions_.Permissions,
): ...
Model of the member who triggered an interaction.
Unlike Member
, this object comes with an extra
permissions
field.
Method generated by attrs for class InteractionMember.
class InteractionMember(guilds.Member):
"""Model of the member who triggered an interaction.
Unlike `hikari.guilds.Member`, this object comes with an extra
`InteractionMember.permissions` field.
"""
permissions: permissions_.Permissions = attr.field(eq=False, hash=False, repr=False)
"""Permissions the member has in the current channel."""
Used to represent a guild bound member …
Interface for any user-like object …
A partial interface for a user …
Mixin for a class that enforces uniqueness by a snowflake ID.
Helper class that provides a standard way to create an ABC using inheritance.
property accent_color : Optional[colors.Color]
The custom banner color for the user, if set else None
.
The official client will decide the default color if not set.
property accent_colour : Optional[colors.Color]
Alias for the accent_color
field.
property avatar_hash : Optional[str]
Avatar hash for the user, if they have one, otherwise None
.
property avatar_url : Optional[files.URL]
Avatar URL for the user, if they have one set.
May be None
if no custom avatar is set. In this case, you
should use default_avatar_url
instead.
property created_at : datetime.datetime
When the object was created.
property default_avatar_url : files.URL
Default avatar URL for this user.
property discriminator : str
Discriminator for the user.
property display_avatar_url : files.URL
Display avatar URL for this user.
property display_name : str
Return the member's display name.
If the member has a nickname, this will return that nickname. Otherwise, it will return the username instead.
str
Nickname
Member.nickname
Username
Member.username
property guild_avatar_hash : Optional[str]
Hash of the member's guild avatar guild if set, else None
.
Note
This takes precedence over Member.avatar_hash
.
property guild_avatar_url : Optional[files.URL]
Guild Avatar URL for the user, if they have one set.
May be None
if no guild avatar is set. In this case, you
should use avatar_hash
or default_avatar_url
instead.
property guild_id : snowflakes.Snowflake
The ID of the guild this member belongs to.
property id : Snowflake
Return the ID of this entity.
Snowflake
property is_deaf : undefined.UndefinedOr[bool]
True
if this member is deafened in the current voice channel.
This will be UNDEFINED
if it's state is
unknown.
property is_mute : undefined.UndefinedOr[bool]
True
if this member is muted in the current voice channel.
This will be UNDEFINED
if it's state is unknown.
property is_pending : undefined.UndefinedOr[bool]
Whether the user has passed the guild's membership screening requirements.
This will be UNDEFINED
if it's state is unknown.
property joined_at : datetime.datetime
The datetime of when this member joined the guild they belong to.
property mention : str
Return a raw mention string for the given member.
If the member has a known nickname, we always return
a bang ("!
") before the ID part of the mention string. This
mimics the behaviour Discord clients tend to provide.
>>> some_member_without_nickname.mention
'<@123456789123456789>'
>>> some_member_with_nickname.mention
'<@!123456789123456789>'
str
property permissions : permissions_.Permissions
Permissions the member has in the current channel.
property raw_communication_disabled_until : Optional[datetime.datetime]
The datetime when this member's timeout will expire.
Will be None
if the member is not timed out.
Note
The datetime might be in the past, so it is recommended to use
communication_disabled_until
method to check if the member is timed
out at the time of the call.
property role_ids : Sequence[snowflakes.Snowflake]
A sequence of the IDs of the member's current roles.
property user : users.User
This member's corresponding user object.
async def add_role(
role: snowflakes.SnowflakeishOr[PartialRole],
*,
reason: undefined.UndefinedOr[str] = UNDEFINED,
) -> None: ...
Inherited from:
Member
.add_role
Add a role to the member.
role
: SnowflakeishOr[PartialRole]
reason
: UndefinedOr[str]
ForbiddenError
MANAGE_ROLES
permission.UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
async def ban(
*,
delete_message_days: undefined.UndefinedOr[int] = UNDEFINED,
reason: undefined.UndefinedOr[str] = UNDEFINED,
) -> None: ...
Ban this member from this guild.
delete_message_days
: UndefinedNoneOr[int]
reason
: UndefinedOr[str]
BadRequestError
ForbiddenError
BAN_MEMBERS
permission.UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
def communication_disabled_until() -> Optional[datetime.datetime]: ...
Inherited from:
Member
.communication_disabled_until
Return when the timeout for this member ends.
Unlike raw_communication_disabled_until
, this will always be
None
if the member is not currently timed out.
Note
The output of this function can depend based on when the function is called.
async def edit(
*,
nickname: undefined.UndefinedNoneOr[str] = UNDEFINED,
nick: undefined.UndefinedNoneOr[str] = UNDEFINED,
roles: undefined.UndefinedOr[snowflakes.SnowflakeishSequence[PartialRole]] = UNDEFINED,
mute: undefined.UndefinedOr[bool] = UNDEFINED,
deaf: undefined.UndefinedOr[bool] = UNDEFINED,
voice_channel: undefined.UndefinedNoneOr[snowflakes.SnowflakeishOr[channels_.GuildVoiceChannel]] = UNDEFINED,
communication_disabled_until: undefined.UndefinedNoneOr[datetime.datetime] = UNDEFINED,
reason: undefined.UndefinedOr[str] = UNDEFINED,
) -> Member: ...
Edit the member.
nickname
: UndefinedNoneOr[str]
If provided, the new nick for the member. If None
,
will remove the members nick.
Requires the MANAGE_NICKNAMES
permission.
nick
: UndefinedNoneOr[str]
nickname
.roles
: UndefinedOr[SnowflakeishSequence[PartialRole]]
If provided, the new roles for the member.
Requires the MANAGE_ROLES
permission.
mute
: UndefinedOr[bool]
If provided, the new server mute state for the member.
Requires the MUTE_MEMBERS
permission.
deaf
: UndefinedOr[bool]
If provided, the new server deaf state for the member.
Requires the DEAFEN_MEMBERS
permission.
voice_channel
: UndefinedOr[SnowflakeishOr[GuildVoiceChannel]]]
If provided, None
or the object or the ID of
an existing voice channel to move the member to.
If None
, will disconnect the member from voice.
Requires the MOVE_MEMBERS
permission and the CONNECT
permission in the original voice channel and the target
voice channel.
Note
If the member is not in a voice channel, this will take no effect.
communication_disabled_until
: UndefinedNoneOr[datetime.datetime]
If provided, the datetime when the timeout (disable communication)
of the member expires, up to 28 days in the future, or None
to remove the timeout from the member.
Requires the MODERATE_MEMBERS
permission.
reason
: UndefinedOr[str]
Member
BadRequestError
ForbiddenError
UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
async def fetch_dm_channel() -> DMChannel: ...
Inherited from:
Member
.fetch_dm_channel
Fetch the DM channel for this user.
DMChannel
UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
async def fetch_roles() -> Sequence[Role]: ...
Inherited from:
Member
.fetch_roles
Fetch an up-to-date view of this member's roles from the API.
UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
async def fetch_self() -> Member: ...
Inherited from:
Member
.fetch_self
Fetch an up-to-date view of this member from the API.
Member
UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
def get_guild() -> Optional[Guild]: ...
Inherited from:
Member
.get_guild
Return the guild associated with this member.
def get_presence() -> Optional[presences_.MemberPresence]: ...
Inherited from:
Member
.get_presence
Get the cached presence for this member, if known.
Presence info includes user status and activities.
This requires the GUILD_PRESENCES
intent to be enabled.
Optional[MemberPresence]
None
if not known.def get_roles() -> Sequence[Role]: ...
Inherited from:
Member
.get_roles
Return the roles the user has.
This will be empty if the roles are missing from the cache.
def get_top_role() -> Optional[Role]: ...
Inherited from:
Member
.get_top_role
Return the highest role the member has.
async def kick(
*,
reason: undefined.UndefinedOr[str] = UNDEFINED,
) -> None: ...
Kick this member from this guild.
reason
: UndefinedOr[str]
BadRequestError
ForbiddenError
KICK_MEMBERS
permission.UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
def make_avatar_url(
*,
ext: Optional[str] = None,
size: int = 4096,
) -> Optional[files.URL]: ...
Inherited from:
Member
.make_avatar_url
Generate the avatar URL for this user, if set.
If no custom avatar is set, this returns None
. You can then
use the default_avatar_url
attribute instead to fetch the displayed
URL.
ext
: Optional[str]
The ext to use for this URL, defaults to png
or gif
.
Supports png
, jpeg
, jpg
, webp
and gif
(when
animated). Will be ignored for default avatars which can only be
png
.
If None
, then the correct default extension is
determined based on whether the icon is animated or not.
size
: int
4096
.
Can be any power of two between 16 and 4096.
Will be ignored for default avatars.ValueError
size
is not a power of two or not between 16 and 4096.def make_guild_avatar_url(
*,
ext: Optional[str] = None,
size: int = 4096,
) -> Optional[files.URL]: ...
Inherited from:
Member
.make_guild_avatar_url
Generate the guild specific avatar url for this member, if set.
If no guild avatar is set, this returns None
. You can then
use the make_avatar_url
to get their global custom avatar or
default_avatar_url
if they have no custom avatar set.
ext
: Optional[str]
The ext to use for this URL, defaults to png
or gif
.
Supports png
, jpeg
, jpg
, webp
and gif
(when
animated). Will be ignored for default avatars which can only be
png
.
If None
, then the correct default extension is
determined based on whether the icon is animated or not.
size
: int
4096
.
Can be any power of two between 16 and 4096.
Will be ignored for default avatars.ValueError
size
is not a power of two or not between 16 and 4096.async def remove_role(
role: snowflakes.SnowflakeishOr[PartialRole],
*,
reason: undefined.UndefinedOr[str] = UNDEFINED,
) -> None: ...
Inherited from:
Member
.remove_role
Remove a role from the member.
role
: SnowflakeishOr[PartialRole]
reason
: UndefinedOr[str]
ForbiddenError
MANAGE_ROLES
permission.UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
async def send(
content: undefined.UndefinedOr[Any] = UNDEFINED,
*,
attachment: undefined.UndefinedOr[files.Resourceish] = UNDEFINED,
attachments: undefined.UndefinedOr[Sequence[files.Resourceish]] = UNDEFINED,
component: undefined.UndefinedOr[special_endpoints.ComponentBuilder] = UNDEFINED,
components: undefined.UndefinedOr[Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED,
embed: undefined.UndefinedOr[embeds_.Embed] = UNDEFINED,
embeds: undefined.UndefinedOr[Sequence[embeds_.Embed]] = UNDEFINED,
tts: undefined.UndefinedOr[bool] = UNDEFINED,
reply: undefined.UndefinedOr[snowflakes.SnowflakeishOr[messages.PartialMessage]] = UNDEFINED,
mentions_everyone: undefined.UndefinedOr[bool] = UNDEFINED,
mentions_reply: undefined.UndefinedOr[bool] = UNDEFINED,
user_mentions: undefined.UndefinedOr[Union[snowflakes.SnowflakeishSequence[PartialUser], bool]] = UNDEFINED,
role_mentions: undefined.UndefinedOr[Union[snowflakes.SnowflakeishSequence[guilds.PartialRole], bool]] = UNDEFINED,
) -> messages.Message: ...
Send a message to this user in DM's.
content
: UndefinedOr[Any]
If provided, the message contents. If
UNDEFINED
, then nothing will be sent
in the content. Any other value here will be cast to a
str
.
If this is a 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.
Likewise, if this is a Resource
, then the
content is instead treated as an attachment if no attachment
and
no attachments
kwargs are provided.
attachment
: UndefinedOr[Resourceish],
attachments
: UndefinedOr[Sequence[Resourceish]],
component
: UndefinedOr[ComponentBuilder]
components
: UndefinedOr[Sequence[ComponentBuilder]]
embed
: UndefinedOr[Embed]
embeds
: UndefinedOr[Sequence[Embed]]
tts
: UndefinedOr[bool]
reply
: UndefinedOr[SnowflakeishOr[PartialMessage]]
mentions_everyone
: UndefinedOr[bool]
mentions_reply
: UndefinedOr[bool]
If provided, whether to mention the author of the message that is being replied to.
This will not do anything if not being used with reply
.
user_mentions
: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]]
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
Snowflake
, or
PartialUser
derivatives to enforce mentioning
specific users.role_mentions
: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]]
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
Snowflake
, or
PartialRole
derivatives to enforce mentioning
specific roles.Note
Attachments can be passed as many different things, to aid in convenience.
pathlib.PurePath
or str
to a valid URL, the
resource at the given URL will be streamed to Discord when
sending the message. Subclasses of
WebResource
such as
URL
,
Attachment
,
Emoji
,
EmbedResource
, etc will also be uploaded this way.
This will use bit-inception, so only a small percentage of the
resource will remain in memory at any one time, thus aiding in
scalability.Bytes
is passed, or a str
that contains a valid data URI is passed, then this is uploaded
with a randomized file name if not provided.File
, pathlib.PurePath
or
str
that is an absolute or relative path to a file
on your file system is passed, then this resource is uploaded
as an attachment using non-blocking code internally and streamed
using bit-inception where possible. This depends on the
type of concurrent.futures.Executor
that is being used for
the application (default is a thread pool which supports this
behaviour).Message
ValueError
role_mentions
or user_mentions
.TypeError
attachment
and attachments
are specified.BadRequestError
reply
not found or not in the same
channel; too many components.UnauthorizedError
ForbiddenError
SEND_MESSAGES
in the channel or the
person you are trying to message has the DM's disabled.NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
async def unban(
*,
reason: undefined.UndefinedOr[str] = UNDEFINED,
) -> None: ...
Unban this member from the guild.
reason
: UndefinedOr[str]
BadRequestError
ForbiddenError
BAN_MEMBERS
permission.UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
class InteractionType (
value: Any,
): ...
The type of an interaction.
class InteractionType(int, enums.Enum):
"""The type of an interaction."""
# PING isn't here as it should be handled as internal detail of the REST
# server rather than as a part of the public interface.
APPLICATION_COMMAND = 2
"""An interaction triggered by a user calling an application command."""
MESSAGE_COMPONENT = 3
"""An interaction triggered by a user calling a message component."""
AUTOCOMPLETE = 4
"""An interaction triggered by a user typing in a slash command option."""
int([x]) -> integer int(x, base=10) -> integer …
Clone of Python's enum.Enum
implementation …
property value
Return the value of the enum member.
const APPLICATION_COMMAND = 2
An interaction triggered by a user calling an application command.
const AUTOCOMPLETE = 4
An interaction triggered by a user typing in a slash command option.
const MESSAGE_COMPONENT = 3
An interaction triggered by a user calling a message component.
class MessageResponseMixin (
*,
app: traits.RESTAware,
id: snowflakes.Snowflake,
application_id: snowflakes.Snowflake,
type: Union[InteractionType, int],
token: str,
version: int,
): ...
Mixin' class for all interaction types which can be responded to with a message.
Method generated by attrs for class PartialInteraction.
class MessageResponseMixin(PartialInteraction, typing.Generic[_CommandResponseTypesT]):
"""Mixin' class for all interaction types which can be responded to with a message."""
__slots__: typing.Sequence[str] = ()
async def fetch_initial_response(self) -> messages.Message:
"""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.
"""
return await self.app.rest.fetch_interaction_response(self.application_id, self.token)
async def create_initial_response(
self,
response_type: _CommandResponseTypesT,
content: undefined.UndefinedOr[typing.Any] = undefined.UNDEFINED,
*,
flags: typing.Union[int, messages.MessageFlag, undefined.UndefinedType] = undefined.UNDEFINED,
tts: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
attachment: undefined.UndefinedOr[files.Resourceish] = undefined.UNDEFINED,
attachments: undefined.UndefinedOr[typing.Sequence[files.Resourceish]] = undefined.UNDEFINED,
component: undefined.UndefinedOr[special_endpoints.ComponentBuilder] = undefined.UNDEFINED,
components: undefined.UndefinedOr[typing.Sequence[special_endpoints.ComponentBuilder]] = undefined.UNDEFINED,
embed: undefined.UndefinedOr[embeds_.Embed] = undefined.UNDEFINED,
embeds: undefined.UndefinedOr[typing.Sequence[embeds_.Embed]] = undefined.UNDEFINED,
mentions_everyone: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
user_mentions: undefined.UndefinedOr[
typing.Union[snowflakes.SnowflakeishSequence[users.PartialUser], bool]
] = undefined.UNDEFINED,
role_mentions: undefined.UndefinedOr[
typing.Union[snowflakes.SnowflakeishSequence[guilds.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.
Parameters
----------
response_type : typing.Union[builtins.int, CommandResponseTypesT]
The type of interaction response this is.
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 a
`builtins.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.
attachment : hikari.undefined.UndefinedOr[hikari.files.Resourceish],
If provided, the message attachment. This can be a resource,
or string of a path on your computer or a URL.
attachments : hikari.undefined.UndefinedOr[typing.Sequence[hikari.files.Resourceish]],
If provided, the message attachments. These can be resources, or
strings consisting of paths on your computer or URLs.
component : hikari.undefined.UndefinedOr[hikari.api.special_endpoints.ComponentBuilder]
If provided, builder object of the component to include in this message.
components : hikari.undefined.UndefinedOr[typing.Sequence[hikari.api.special_endpoints.ComponentBuilder]]
If provided, a sequence of the component builder objects to include
in this message.
embed : hikari.undefined.UndefinedOr[hikari.embeds.Embed]
If provided, the message embed.
embeds : hikari.undefined.UndefinedOr[typing.Sequence[hikari.embeds.Embed]]
If provided, the message embeds.
flags : typing.Union[builtins.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[builtins.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[builtins.bool]
If provided, whether the message should parse @everyone/@here
mentions.
user_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], builtins.bool]]
If provided, and `builtins.True`, all user mentions will be detected.
If provided, and `builtins.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.
role_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], builtins.bool]]
If provided, and `builtins.True`, all role mentions will be detected.
If provided, and `builtins.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.
Raises
------
builtins.ValueError
If more than 100 unique objects/entities are passed for
`role_mentions` or `user_mentions`.
builtins.TypeError
If both `embed` and `embeds` 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.
""" # noqa: E501 - Line too long
await self.app.rest.create_interaction_response(
self.id,
self.token,
response_type,
content,
tts=tts,
attachment=attachment,
attachments=attachments,
component=component,
components=components,
embed=embed,
embeds=embeds,
flags=flags,
mentions_everyone=mentions_everyone,
user_mentions=user_mentions,
role_mentions=role_mentions,
)
async def edit_initial_response(
self,
content: undefined.UndefinedNoneOr[typing.Any] = undefined.UNDEFINED,
*,
attachment: undefined.UndefinedOr[files.Resourceish] = undefined.UNDEFINED,
attachments: undefined.UndefinedOr[typing.Sequence[files.Resourceish]] = undefined.UNDEFINED,
component: undefined.UndefinedNoneOr[special_endpoints.ComponentBuilder] = undefined.UNDEFINED,
components: undefined.UndefinedNoneOr[
typing.Sequence[special_endpoints.ComponentBuilder]
] = undefined.UNDEFINED,
embed: undefined.UndefinedNoneOr[embeds_.Embed] = undefined.UNDEFINED,
embeds: undefined.UndefinedNoneOr[typing.Sequence[embeds_.Embed]] = undefined.UNDEFINED,
replace_attachments: bool = False,
mentions_everyone: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
user_mentions: undefined.UndefinedOr[
typing.Union[snowflakes.SnowflakeishSequence[users.PartialUser], bool]
] = undefined.UNDEFINED,
role_mentions: undefined.UndefinedOr[
typing.Union[snowflakes.SnowflakeishSequence[guilds.PartialRole], bool]
] = undefined.UNDEFINED,
) -> messages.Message:
"""Edit the initial response of this command interaction.
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 a
`builtins.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.
attachment : hikari.undefined.UndefinedOr[hikari.files.Resourceish]
If provided, the attachment to set on the message. If
`hikari.undefined.UNDEFINED`, the previous attachment, if
present, is not changed. If this is `builtins.None`, then the
attachment is removed, if present. Otherwise, the new attachment
that was provided will be attached.
attachments : hikari.undefined.UndefinedOr[typing.Sequence[hikari.files.Resourceish]]
If provided, the attachments to set on the message. If
`hikari.undefined.UNDEFINED`, the previous attachments, if
present, are not changed. If this is `builtins.None`, 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
`builtins.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 `builtins.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 is `builtins.None` 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 is `builtins.None` then any present embeds are removed.
Otherwise, the new embeds that were provided will be used as the
replacement.
replace_attachments: bool
Whether to replace the attachments with the provided ones. Defaults
to `builtins.False`.
Note this will also overwrite the embed attachments.
mentions_everyone : hikari.undefined.UndefinedOr[builtins.bool]
If provided, whether the message should parse @everyone/@here
mentions.
user_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], builtins.bool]]
If provided, and `builtins.True`, all user mentions will be detected.
If provided, and `builtins.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.
role_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], builtins.bool]]
If provided, and `builtins.True`, all role mentions will be detected.
If provided, and `builtins.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.
!!! 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 one of `mentions_everyone`, `user_mentions`, or
`role_mentions`, then all others will default to `builtins.False`,
even if they were enabled previously.
This is a limitation of Discord's design. If in doubt, specify all three of
them each time.
Returns
-------
hikari.messages.Message
The edited message.
Raises
------
builtins.ValueError
If more than 100 unique objects/entities are passed for
`role_mentions` or `user_mentions`.
builtins.TypeError
If both `embed` and `embeds` 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.
""" # noqa: E501 - Line too long
return await self.app.rest.edit_interaction_response(
self.application_id,
self.token,
content,
attachment=attachment,
attachments=attachments,
component=component,
components=components,
embed=embed,
embeds=embeds,
replace_attachments=replace_attachments,
mentions_everyone=mentions_everyone,
user_mentions=user_mentions,
role_mentions=role_mentions,
)
async def delete_initial_response(self) -> None:
"""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.
"""
await self.app.rest.delete_interaction_response(self.application_id, self.token)
Represents a command interaction on Discord …
Represents a component interaction on Discord …
The base model for all interaction models …
Mixin for a class that enforces uniqueness by a snowflake ID.
An abstract class with logic for executing entities as webhooks.
Helper class that provides a standard way to create an ABC using inheritance.
Abstract base class for generic types …
property app : traits.RESTAware
The client application that models may use for procedures.
property application_id : snowflakes.Snowflake
ID of the application this interaction belongs to.
property created_at : datetime.datetime
When the object was created.
property id : snowflakes.Snowflake
Return the ID of this entity.
Snowflake
property type : Union[InteractionType, int]
The type of interaction this is.
property webhook_id : Snowflake
ID used to execute this entity as a webhook.
Snowflake
async def create_initial_response(
response_type: _CommandResponseTypesT,
content: undefined.UndefinedOr[Any] = UNDEFINED,
*,
flags: Union[int, messages.MessageFlag, undefined.UndefinedType] = UNDEFINED,
tts: undefined.UndefinedOr[bool] = UNDEFINED,
attachment: undefined.UndefinedOr[files.Resourceish] = UNDEFINED,
attachments: undefined.UndefinedOr[Sequence[files.Resourceish]] = UNDEFINED,
component: undefined.UndefinedOr[special_endpoints.ComponentBuilder] = UNDEFINED,
components: undefined.UndefinedOr[Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED,
embed: undefined.UndefinedOr[embeds_.Embed] = UNDEFINED,
embeds: undefined.UndefinedOr[Sequence[embeds_.Embed]] = UNDEFINED,
mentions_everyone: undefined.UndefinedOr[bool] = UNDEFINED,
user_mentions: undefined.UndefinedOr[Union[snowflakes.SnowflakeishSequence[users.PartialUser], bool]] = UNDEFINED,
role_mentions: undefined.UndefinedOr[Union[snowflakes.SnowflakeishSequence[guilds.PartialRole], bool]] = 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 NotFoundError
.
This includes if the REST interaction server has already responded
to the request.
content
: UndefinedOr[Any]
If provided, the message contents. If
UNDEFINED
, then nothing will be sent
in the content. Any other value here will be cast to a
str
.
If this is a 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.
attachment
: UndefinedOr[Resourceish],
attachments
: UndefinedOr[Sequence[Resourceish]],
component
: UndefinedOr[ComponentBuilder]
components
: UndefinedOr[Sequence[ComponentBuilder]]
embed
: UndefinedOr[Embed]
embeds
: UndefinedOr[Sequence[Embed]]
flags
: Union[int, MessageFlag, UndefinedType]
If provided, the message flags this response should have.
As of writing the only message flag which can be set here is
EPHEMERAL
.
tts
: UndefinedOr[bool]
mentions_everyone
: UndefinedOr[bool]
user_mentions
: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]]
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
Snowflake
, or
PartialUser
derivatives to enforce mentioning
specific users.role_mentions
: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]]
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
Snowflake
, or
PartialRole
derivatives to enforce mentioning
specific roles.ValueError
role_mentions
or user_mentions
.TypeError
embed
and embeds
are specified.BadRequestError
UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
async def create_initial_response(
self,
response_type: _CommandResponseTypesT,
content: undefined.UndefinedOr[typing.Any] = undefined.UNDEFINED,
*,
flags: typing.Union[int, messages.MessageFlag, undefined.UndefinedType] = undefined.UNDEFINED,
tts: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
attachment: undefined.UndefinedOr[files.Resourceish] = undefined.UNDEFINED,
attachments: undefined.UndefinedOr[typing.Sequence[files.Resourceish]] = undefined.UNDEFINED,
component: undefined.UndefinedOr[special_endpoints.ComponentBuilder] = undefined.UNDEFINED,
components: undefined.UndefinedOr[typing.Sequence[special_endpoints.ComponentBuilder]] = undefined.UNDEFINED,
embed: undefined.UndefinedOr[embeds_.Embed] = undefined.UNDEFINED,
embeds: undefined.UndefinedOr[typing.Sequence[embeds_.Embed]] = undefined.UNDEFINED,
mentions_everyone: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
user_mentions: undefined.UndefinedOr[
typing.Union[snowflakes.SnowflakeishSequence[users.PartialUser], bool]
] = undefined.UNDEFINED,
role_mentions: undefined.UndefinedOr[
typing.Union[snowflakes.SnowflakeishSequence[guilds.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.
Parameters
----------
response_type : typing.Union[builtins.int, CommandResponseTypesT]
The type of interaction response this is.
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 a
`builtins.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.
attachment : hikari.undefined.UndefinedOr[hikari.files.Resourceish],
If provided, the message attachment. This can be a resource,
or string of a path on your computer or a URL.
attachments : hikari.undefined.UndefinedOr[typing.Sequence[hikari.files.Resourceish]],
If provided, the message attachments. These can be resources, or
strings consisting of paths on your computer or URLs.
component : hikari.undefined.UndefinedOr[hikari.api.special_endpoints.ComponentBuilder]
If provided, builder object of the component to include in this message.
components : hikari.undefined.UndefinedOr[typing.Sequence[hikari.api.special_endpoints.ComponentBuilder]]
If provided, a sequence of the component builder objects to include
in this message.
embed : hikari.undefined.UndefinedOr[hikari.embeds.Embed]
If provided, the message embed.
embeds : hikari.undefined.UndefinedOr[typing.Sequence[hikari.embeds.Embed]]
If provided, the message embeds.
flags : typing.Union[builtins.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[builtins.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[builtins.bool]
If provided, whether the message should parse @everyone/@here
mentions.
user_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], builtins.bool]]
If provided, and `builtins.True`, all user mentions will be detected.
If provided, and `builtins.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.
role_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], builtins.bool]]
If provided, and `builtins.True`, all role mentions will be detected.
If provided, and `builtins.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.
Raises
------
builtins.ValueError
If more than 100 unique objects/entities are passed for
`role_mentions` or `user_mentions`.
builtins.TypeError
If both `embed` and `embeds` 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.
""" # noqa: E501 - Line too long
await self.app.rest.create_interaction_response(
self.id,
self.token,
response_type,
content,
tts=tts,
attachment=attachment,
attachments=attachments,
component=component,
components=components,
embed=embed,
embeds=embeds,
flags=flags,
mentions_everyone=mentions_everyone,
user_mentions=user_mentions,
role_mentions=role_mentions,
)
async def delete_initial_response() -> None: ...
Delete the initial response of this interaction.
UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
async def delete_initial_response(self) -> None:
"""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.
"""
await self.app.rest.delete_interaction_response(self.application_id, self.token)
async def delete_message(
message: snowflakes.SnowflakeishOr[messages_.Message],
) -> None: ...
Inherited from:
PartialInteraction
.delete_message
Delete a given message in a given channel.
message
: SnowflakeishOr[PartialMessage]
ValueError
token
is not available.UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
async def edit_initial_response(
content: undefined.UndefinedNoneOr[Any] = UNDEFINED,
*,
attachment: undefined.UndefinedOr[files.Resourceish] = UNDEFINED,
attachments: undefined.UndefinedOr[Sequence[files.Resourceish]] = UNDEFINED,
component: undefined.UndefinedNoneOr[special_endpoints.ComponentBuilder] = UNDEFINED,
components: undefined.UndefinedNoneOr[Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED,
embed: undefined.UndefinedNoneOr[embeds_.Embed] = UNDEFINED,
embeds: undefined.UndefinedNoneOr[Sequence[embeds_.Embed]] = UNDEFINED,
replace_attachments: bool = False,
mentions_everyone: undefined.UndefinedOr[bool] = UNDEFINED,
user_mentions: undefined.UndefinedOr[Union[snowflakes.SnowflakeishSequence[users.PartialUser], bool]] = UNDEFINED,
role_mentions: undefined.UndefinedOr[Union[snowflakes.SnowflakeishSequence[guilds.PartialRole], bool]] = UNDEFINED,
) -> messages.Message: ...
Edit the initial response of this command interaction.
content
: UndefinedNoneOr[Any]
If provided, the message contents. If
UNDEFINED
, then nothing will be sent
in the content. Any other value here will be cast to a
str
.
If this is a Embed
and neither the
embed
or embeds
kwargs are provided or if this is a
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 Resource
, then the
content is instead treated as an attachment if no attachment
and
no attachments
kwargs are provided.
attachment
: UndefinedOr[Resourceish]
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.attachments
: UndefinedOr[Sequence[Resourceish]]
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.component
: UndefinedNoneOr[ComponentBuilder]
None
will remove all components.components
: UndefinedNoneOr[Sequence[ComponentBuilder]]
None
or an empty sequence will
remove all components.embed
: UndefinedNoneOr[Embed]
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.embeds
: UndefinedNoneOr[Sequence[Embed]]
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.replace_attachments
: bool
Whether to replace the attachments with the provided ones. Defaults
to False
.
Note this will also overwrite the embed attachments.
mentions_everyone
: UndefinedOr[bool]
user_mentions
: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]]
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
Snowflake
, or
PartialUser
derivatives to enforce mentioning
specific users.role_mentions
: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]]
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
Snowflake
, or
PartialRole
derivatives to enforce mentioning
specific roles.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 one of mentions_everyone
, user_mentions
, or
role_mentions
, then all others will default to False
,
even if they were enabled previously.
This is a limitation of Discord's design. If in doubt, specify all three of them each time.
Message
ValueError
role_mentions
or user_mentions
.TypeError
embed
and embeds
are specified.BadRequestError
UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
async def edit_initial_response(
self,
content: undefined.UndefinedNoneOr[typing.Any] = undefined.UNDEFINED,
*,
attachment: undefined.UndefinedOr[files.Resourceish] = undefined.UNDEFINED,
attachments: undefined.UndefinedOr[typing.Sequence[files.Resourceish]] = undefined.UNDEFINED,
component: undefined.UndefinedNoneOr[special_endpoints.ComponentBuilder] = undefined.UNDEFINED,
components: undefined.UndefinedNoneOr[
typing.Sequence[special_endpoints.ComponentBuilder]
] = undefined.UNDEFINED,
embed: undefined.UndefinedNoneOr[embeds_.Embed] = undefined.UNDEFINED,
embeds: undefined.UndefinedNoneOr[typing.Sequence[embeds_.Embed]] = undefined.UNDEFINED,
replace_attachments: bool = False,
mentions_everyone: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
user_mentions: undefined.UndefinedOr[
typing.Union[snowflakes.SnowflakeishSequence[users.PartialUser], bool]
] = undefined.UNDEFINED,
role_mentions: undefined.UndefinedOr[
typing.Union[snowflakes.SnowflakeishSequence[guilds.PartialRole], bool]
] = undefined.UNDEFINED,
) -> messages.Message:
"""Edit the initial response of this command interaction.
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 a
`builtins.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.
attachment : hikari.undefined.UndefinedOr[hikari.files.Resourceish]
If provided, the attachment to set on the message. If
`hikari.undefined.UNDEFINED`, the previous attachment, if
present, is not changed. If this is `builtins.None`, then the
attachment is removed, if present. Otherwise, the new attachment
that was provided will be attached.
attachments : hikari.undefined.UndefinedOr[typing.Sequence[hikari.files.Resourceish]]
If provided, the attachments to set on the message. If
`hikari.undefined.UNDEFINED`, the previous attachments, if
present, are not changed. If this is `builtins.None`, 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
`builtins.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 `builtins.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 is `builtins.None` 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 is `builtins.None` then any present embeds are removed.
Otherwise, the new embeds that were provided will be used as the
replacement.
replace_attachments: bool
Whether to replace the attachments with the provided ones. Defaults
to `builtins.False`.
Note this will also overwrite the embed attachments.
mentions_everyone : hikari.undefined.UndefinedOr[builtins.bool]
If provided, whether the message should parse @everyone/@here
mentions.
user_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], builtins.bool]]
If provided, and `builtins.True`, all user mentions will be detected.
If provided, and `builtins.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.
role_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], builtins.bool]]
If provided, and `builtins.True`, all role mentions will be detected.
If provided, and `builtins.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.
!!! 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 one of `mentions_everyone`, `user_mentions`, or
`role_mentions`, then all others will default to `builtins.False`,
even if they were enabled previously.
This is a limitation of Discord's design. If in doubt, specify all three of
them each time.
Returns
-------
hikari.messages.Message
The edited message.
Raises
------
builtins.ValueError
If more than 100 unique objects/entities are passed for
`role_mentions` or `user_mentions`.
builtins.TypeError
If both `embed` and `embeds` 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.
""" # noqa: E501 - Line too long
return await self.app.rest.edit_interaction_response(
self.application_id,
self.token,
content,
attachment=attachment,
attachments=attachments,
component=component,
components=components,
embed=embed,
embeds=embeds,
replace_attachments=replace_attachments,
mentions_everyone=mentions_everyone,
user_mentions=user_mentions,
role_mentions=role_mentions,
)
async def edit_message(
message: snowflakes.SnowflakeishOr[messages_.Message],
content: undefined.UndefinedNoneOr[Any] = UNDEFINED,
*,
attachment: undefined.UndefinedOr[files.Resourceish] = UNDEFINED,
attachments: undefined.UndefinedOr[Sequence[files.Resourceish]] = UNDEFINED,
component: undefined.UndefinedNoneOr[special_endpoints.ComponentBuilder] = UNDEFINED,
components: undefined.UndefinedNoneOr[Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED,
embed: undefined.UndefinedNoneOr[embeds_.Embed] = UNDEFINED,
embeds: undefined.UndefinedNoneOr[Sequence[embeds_.Embed]] = UNDEFINED,
replace_attachments: bool = False,
mentions_everyone: undefined.UndefinedOr[bool] = UNDEFINED,
user_mentions: undefined.UndefinedOr[Union[snowflakes.SnowflakeishSequence[users_.PartialUser], bool]] = UNDEFINED,
role_mentions: undefined.UndefinedOr[Union[snowflakes.SnowflakeishSequence[guilds_.PartialRole], bool]] = UNDEFINED,
) -> messages_.Message: ...
Inherited from:
PartialInteraction
.edit_message
Edit a message sent by a webhook.
message
: SnowflakeishOr[PartialMessage]
content
: UndefinedNoneOr[Any]
If provided, the message contents. If
UNDEFINED
, then nothing will be sent
in the content. Any other value here will be cast to a
str
.
If this is a Embed
and no embed
nor
no embeds
kwarg is provided, then this will instead
update the embed. This allows for simpler syntax when
sending an embed alone.
Likewise, if this is a Resource
, then the
content is instead treated as an attachment if no attachment
and
no attachments
kwargs are provided.
attachment
: UndefinedOr[Resourceish]
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.attachments
: UndefinedOr[Sequence[Resourceish]]
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.component
: UndefinedNoneOr[ComponentBuilder]
None
will remove all components.components
: UndefinedNoneOr[Sequence[ComponentBuilder]]
None
or an empty sequence will
remove all components.embed
: UndefinedNoneOr[Embed]
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.embeds
: UndefinedNoneOr[Sequence[Embed]]
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.replace_attachments
: bool
Whether to replace the attachments with the provided ones. Defaults
to False
.
Note this will also overwrite the embed attachments.
mentions_everyone
: UndefinedOr[bool]
@everyone
mentions. If
UNDEFINED
, then the previous setting is
not changed. If True
, then @everyone
/@here
mentions
in the message content will show up as mentioning everyone that can
view the chat.user_mentions
: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]]
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
Snowflake
, or
PartialUser
derivatives to enforce mentioning
specific users.role_mentions
: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]]
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
Snowflake
, or
PartialRole
derivatives to enforce mentioning
specific roles.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 non-embed content
, mentions_everyone
,
mentions_reply
, user_mentions
, and role_mentions
will default
to False
as the message will be re-parsed for mentions.
This is a limitation of Discord's design. If in doubt, specify all three of them each time.
Warning
If you specify one of mentions_everyone
, mentions_reply
,
user_mentions
, or role_mentions
, then all others will default to
False
, even if they were enabled previously.
This is a limitation of Discord's design. If in doubt, specify all three of them each time.
Message
ValueError
role_mentions
or user_mentions
or token
is not available.TypeError
attachment
and attachments
are specified or if both
embed
and embeds
are specified.BadRequestError
UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
async def execute(
content: undefined.UndefinedOr[Any] = UNDEFINED,
*,
username: undefined.UndefinedOr[str] = UNDEFINED,
avatar_url: Union[undefined.UndefinedType, str, files.URL] = UNDEFINED,
tts: undefined.UndefinedOr[bool] = UNDEFINED,
attachment: undefined.UndefinedOr[files_.Resourceish] = UNDEFINED,
attachments: undefined.UndefinedOr[Sequence[files_.Resourceish]] = UNDEFINED,
component: undefined.UndefinedOr[special_endpoints.ComponentBuilder] = UNDEFINED,
components: undefined.UndefinedOr[Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED,
embed: undefined.UndefinedOr[embeds_.Embed] = UNDEFINED,
embeds: undefined.UndefinedOr[Sequence[embeds_.Embed]] = UNDEFINED,
mentions_everyone: undefined.UndefinedOr[bool] = UNDEFINED,
user_mentions: undefined.UndefinedOr[Union[snowflakes.SnowflakeishSequence[users_.PartialUser], bool]] = UNDEFINED,
role_mentions: undefined.UndefinedOr[Union[snowflakes.SnowflakeishSequence[guilds_.PartialRole], bool]] = UNDEFINED,
flags: Union[undefined.UndefinedType, int, messages_.MessageFlag] = UNDEFINED,
) -> messages_.Message: ...
Inherited from:
PartialInteraction
.execute
Execute the webhook to create a message.
content
: UndefinedOr[Any]
If provided, the message contents. If
UNDEFINED
, then nothing will be sent
in the content. Any other value here will be cast to a
str
.
If this is a Embed
and no embed
kwarg is
provided, then this will instead update the embed. This allows for
simpler syntax when sending an embed alone.
Likewise, if this is a Resource
, then the
content is instead treated as an attachment if no attachment
and
no attachments
kwargs are provided.
username
: UndefinedOr[str]
avatar_url
: Union[UndefinedType, str, URL]
tts
: UndefinedOr[bool]
attachment
: UndefinedOr[Resourceish]
attachments
: UndefinedOr[Sequence[Resourceish]]
component
: UndefinedOr[ComponentBuilder]
components
: UndefinedOr[Sequence[ComponentBuilder]]
embed
: UndefinedOr[Embed]
embeds
: UndefinedOr[Sequence[Embed]]
mentions_everyone
: UndefinedOr[bool]
user_mentions
: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]]
True
, all mentions will be parsed.
If provided, and False
, no mentions will be parsed.
Alternatively this may be a collection of
Snowflake
, or
PartialUser
derivatives to enforce mentioning
specific users.role_mentions
: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]]
True
, all mentions will be parsed.
If provided, and False
, no mentions will be parsed.
Alternatively this may be a collection of
Snowflake
, or
PartialRole
derivatives to enforce mentioning
specific roles.flags
: Union[UndefinedType, int, MessageFlag]
The flags to set for this webhook message.
Warning
As of writing this can only be set for interaction webhooks and the only settable flag is EPHEMERAL; this field is just ignored for non-interaction webhooks.
Warning
As of writing, username
and avatar_url
are ignored for
interaction webhooks.
Message
NotFoundError
BadRequestError
2000
characters; if neither content, file
or embeds are specified.
If any invalid snowflake IDs are passed; a snowflake may be invalid
due to it being outside of the range of a 64 bit integer.UnauthorizedError
ValueError
ExecutableWebhook.token
is None
or more than 100 unique
objects/entities are passed for role_mentions
or `user_mentions or
if token
is not available.TypeError
attachment
and attachments
are specified.async def fetch_initial_response() -> messages.Message: ...
Fetch the initial response of this interaction.
Message
ForbiddenError
NotFoundError
UnauthorizedError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
async def fetch_initial_response(self) -> messages.Message:
"""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.
"""
return await self.app.rest.fetch_interaction_response(self.application_id, self.token)
async def fetch_message(
message: snowflakes.SnowflakeishOr[messages_.Message],
) -> messages_.Message: ...
Inherited from:
PartialInteraction
.fetch_message
Fetch an old message sent by the webhook.
message
: SnowflakeishOr[PartialMessage]
Message
ValueError
token
is not available.UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
class PartialInteraction (
*,
app: traits.RESTAware,
id: snowflakes.Snowflake,
application_id: snowflakes.Snowflake,
type: Union[InteractionType, int],
token: str,
version: int,
): ...
The base model for all interaction models.
Method generated by attrs for class PartialInteraction.
class PartialInteraction(snowflakes.Unique, webhooks.ExecutableWebhook):
"""The base model for all interaction models."""
app: traits.RESTAware = attr.field(repr=False, eq=False, metadata={attr_extensions.SKIP_DEEP_COPY: True})
"""The client application that models may use for procedures."""
id: snowflakes.Snowflake = attr.field(hash=True, repr=True)
# <<inherited docstring from Unique>>.
application_id: snowflakes.Snowflake = attr.field(eq=False, repr=False)
"""ID of the application this interaction belongs to."""
type: typing.Union[InteractionType, int] = attr.field(eq=False, repr=True)
"""The type of interaction this is."""
token: str = attr.field(eq=False, repr=False)
"""The interaction's token."""
version: int = attr.field(eq=False, repr=True)
"""Version of the interaction system this interaction is under."""
@property
def webhook_id(self) -> snowflakes.Snowflake:
# <<inherited docstring from ExecutableWebhook>>.
return self.application_id
Mixin' class for all interaction types which can be responded to with a message …
Represents a base command interaction on Discord …
Mixin for a class that enforces uniqueness by a snowflake ID.
An abstract class with logic for executing entities as webhooks.
Helper class that provides a standard way to create an ABC using inheritance.
property app : traits.RESTAware
The client application that models may use for procedures.
property application_id : snowflakes.Snowflake
ID of the application this interaction belongs to.
property created_at : datetime.datetime
When the object was created.
property id : snowflakes.Snowflake
Return the ID of this entity.
Snowflake
property type : Union[InteractionType, int]
The type of interaction this is.
property webhook_id : Snowflake
ID used to execute this entity as a webhook.
Snowflake
async def delete_message(
message: snowflakes.SnowflakeishOr[messages_.Message],
) -> None: ...
Inherited from:
ExecutableWebhook
.delete_message
Delete a given message in a given channel.
message
: SnowflakeishOr[PartialMessage]
ValueError
token
is not available.UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
async def edit_message(
message: snowflakes.SnowflakeishOr[messages_.Message],
content: undefined.UndefinedNoneOr[Any] = UNDEFINED,
*,
attachment: undefined.UndefinedOr[files.Resourceish] = UNDEFINED,
attachments: undefined.UndefinedOr[Sequence[files.Resourceish]] = UNDEFINED,
component: undefined.UndefinedNoneOr[special_endpoints.ComponentBuilder] = UNDEFINED,
components: undefined.UndefinedNoneOr[Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED,
embed: undefined.UndefinedNoneOr[embeds_.Embed] = UNDEFINED,
embeds: undefined.UndefinedNoneOr[Sequence[embeds_.Embed]] = UNDEFINED,
replace_attachments: bool = False,
mentions_everyone: undefined.UndefinedOr[bool] = UNDEFINED,
user_mentions: undefined.UndefinedOr[Union[snowflakes.SnowflakeishSequence[users_.PartialUser], bool]] = UNDEFINED,
role_mentions: undefined.UndefinedOr[Union[snowflakes.SnowflakeishSequence[guilds_.PartialRole], bool]] = UNDEFINED,
) -> messages_.Message: ...
Inherited from:
ExecutableWebhook
.edit_message
Edit a message sent by a webhook.
message
: SnowflakeishOr[PartialMessage]
content
: UndefinedNoneOr[Any]
If provided, the message contents. If
UNDEFINED
, then nothing will be sent
in the content. Any other value here will be cast to a
str
.
If this is a Embed
and no embed
nor
no embeds
kwarg is provided, then this will instead
update the embed. This allows for simpler syntax when
sending an embed alone.
Likewise, if this is a Resource
, then the
content is instead treated as an attachment if no attachment
and
no attachments
kwargs are provided.
attachment
: UndefinedOr[Resourceish]
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.attachments
: UndefinedOr[Sequence[Resourceish]]
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.component
: UndefinedNoneOr[ComponentBuilder]
None
will remove all components.components
: UndefinedNoneOr[Sequence[ComponentBuilder]]
None
or an empty sequence will
remove all components.embed
: UndefinedNoneOr[Embed]
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.embeds
: UndefinedNoneOr[Sequence[Embed]]
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.replace_attachments
: bool
Whether to replace the attachments with the provided ones. Defaults
to False
.
Note this will also overwrite the embed attachments.
mentions_everyone
: UndefinedOr[bool]
@everyone
mentions. If
UNDEFINED
, then the previous setting is
not changed. If True
, then @everyone
/@here
mentions
in the message content will show up as mentioning everyone that can
view the chat.user_mentions
: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]]
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
Snowflake
, or
PartialUser
derivatives to enforce mentioning
specific users.role_mentions
: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]]
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
Snowflake
, or
PartialRole
derivatives to enforce mentioning
specific roles.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 non-embed content
, mentions_everyone
,
mentions_reply
, user_mentions
, and role_mentions
will default
to False
as the message will be re-parsed for mentions.
This is a limitation of Discord's design. If in doubt, specify all three of them each time.
Warning
If you specify one of mentions_everyone
, mentions_reply
,
user_mentions
, or role_mentions
, then all others will default to
False
, even if they were enabled previously.
This is a limitation of Discord's design. If in doubt, specify all three of them each time.
Message
ValueError
role_mentions
or user_mentions
or token
is not available.TypeError
attachment
and attachments
are specified or if both
embed
and embeds
are specified.BadRequestError
UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
async def execute(
content: undefined.UndefinedOr[Any] = UNDEFINED,
*,
username: undefined.UndefinedOr[str] = UNDEFINED,
avatar_url: Union[undefined.UndefinedType, str, files.URL] = UNDEFINED,
tts: undefined.UndefinedOr[bool] = UNDEFINED,
attachment: undefined.UndefinedOr[files_.Resourceish] = UNDEFINED,
attachments: undefined.UndefinedOr[Sequence[files_.Resourceish]] = UNDEFINED,
component: undefined.UndefinedOr[special_endpoints.ComponentBuilder] = UNDEFINED,
components: undefined.UndefinedOr[Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED,
embed: undefined.UndefinedOr[embeds_.Embed] = UNDEFINED,
embeds: undefined.UndefinedOr[Sequence[embeds_.Embed]] = UNDEFINED,
mentions_everyone: undefined.UndefinedOr[bool] = UNDEFINED,
user_mentions: undefined.UndefinedOr[Union[snowflakes.SnowflakeishSequence[users_.PartialUser], bool]] = UNDEFINED,
role_mentions: undefined.UndefinedOr[Union[snowflakes.SnowflakeishSequence[guilds_.PartialRole], bool]] = UNDEFINED,
flags: Union[undefined.UndefinedType, int, messages_.MessageFlag] = UNDEFINED,
) -> messages_.Message: ...
Inherited from:
ExecutableWebhook
.execute
Execute the webhook to create a message.
content
: UndefinedOr[Any]
If provided, the message contents. If
UNDEFINED
, then nothing will be sent
in the content. Any other value here will be cast to a
str
.
If this is a Embed
and no embed
kwarg is
provided, then this will instead update the embed. This allows for
simpler syntax when sending an embed alone.
Likewise, if this is a Resource
, then the
content is instead treated as an attachment if no attachment
and
no attachments
kwargs are provided.
username
: UndefinedOr[str]
avatar_url
: Union[UndefinedType, str, URL]
tts
: UndefinedOr[bool]
attachment
: UndefinedOr[Resourceish]
attachments
: UndefinedOr[Sequence[Resourceish]]
component
: UndefinedOr[ComponentBuilder]
components
: UndefinedOr[Sequence[ComponentBuilder]]
embed
: UndefinedOr[Embed]
embeds
: UndefinedOr[Sequence[Embed]]
mentions_everyone
: UndefinedOr[bool]
user_mentions
: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]]
True
, all mentions will be parsed.
If provided, and False
, no mentions will be parsed.
Alternatively this may be a collection of
Snowflake
, or
PartialUser
derivatives to enforce mentioning
specific users.role_mentions
: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]]
True
, all mentions will be parsed.
If provided, and False
, no mentions will be parsed.
Alternatively this may be a collection of
Snowflake
, or
PartialRole
derivatives to enforce mentioning
specific roles.flags
: Union[UndefinedType, int, MessageFlag]
The flags to set for this webhook message.
Warning
As of writing this can only be set for interaction webhooks and the only settable flag is EPHEMERAL; this field is just ignored for non-interaction webhooks.
Warning
As of writing, username
and avatar_url
are ignored for
interaction webhooks.
Message
NotFoundError
BadRequestError
2000
characters; if neither content, file
or embeds are specified.
If any invalid snowflake IDs are passed; a snowflake may be invalid
due to it being outside of the range of a 64 bit integer.UnauthorizedError
ValueError
ExecutableWebhook.token
is None
or more than 100 unique
objects/entities are passed for role_mentions
or `user_mentions or
if token
is not available.TypeError
attachment
and attachments
are specified.async def fetch_message(
message: snowflakes.SnowflakeishOr[messages_.Message],
) -> messages_.Message: ...
Inherited from:
ExecutableWebhook
.fetch_message
Fetch an old message sent by the webhook.
message
: SnowflakeishOr[PartialMessage]
Message
ValueError
token
is not available.UnauthorizedError
NotFoundError
RateLimitTooLongError
max_rate_limit
when making a request.RateLimitedError
InternalServerError
class ResponseType (
value: Any,
): ...
The type of an interaction response.
class ResponseType(int, enums.Enum):
"""The type of an interaction response."""
# PONG isn't here as it should be handled as internal detail of the REST
# server rather than as a part of the public interface.
# Type 2 and 3 aren't included as they were deprecated/removed by Discord.
MESSAGE_CREATE = 4
"""An immediate message response to an interaction.
* `InteractionType.APPLICATION_COMMAND`
* `InteractionType.MESSAGE_COMPONENT`
"""
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:
* `InteractionType.APPLICATION_COMMAND`
* `InteractionType.MESSAGE_COMPONENT`
"""
DEFERRED_MESSAGE_UPDATE = 6
"""Acknowledge an interaction with the intention to edit its message later.
This is valid for the following interaction types:
* `InteractionType.MESSAGE_COMPONENT`
"""
MESSAGE_UPDATE = 7
"""An immediate interaction response with instructions on how to update its message.
This is valid for the following interaction types:
* `InteractionType.MESSAGE_COMPONENT`
"""
AUTOCOMPLETE = 8
"""Respond to an autocomplete interaction with suggested choices.
This is valid for the following interaction types:
* `InteractionType.AUTOCOMPLETE`
"""
int([x]) -> integer int(x, base=10) -> integer …
Clone of Python's enum.Enum
implementation …
property value
Return the value of the enum member.
const AUTOCOMPLETE = 8
Respond to an autocomplete interaction with suggested choices.
This is valid for the following interaction types:
const 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:
const DEFERRED_MESSAGE_UPDATE = 6
Acknowledge an interaction with the intention to edit its message later.
This is valid for the following interaction types:
const MESSAGE_CREATE = 4
An immediate message response to an interaction.
const MESSAGE_UPDATE = 7
An immediate interaction response with instructions on how to update its message.
This is valid for the following interaction types: