hikari.interactions.base_interactions
Base classes and enums inherited and used throughout the interactions flow.
View Source
# -*- 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.Sequence[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[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 `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[int, hikari.messages.MessageFlag, hikari.undefined.UndefinedType] If provided, the message flags this response should have. As of writing the only message flag which can be set here is `hikari.messages.MessageFlag.EPHEMERAL`. tts : hikari.undefined.UndefinedOr[bool] If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system. mentions_everyone : hikari.undefined.UndefinedOr[bool] If provided, whether the message should parse @everyone/@here mentions. user_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]] If provided, and `True`, all user mentions will be detected. If provided, and `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], bool]] If provided, and `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 `hikari.snowflakes.Snowflake`, or `hikari.guilds.PartialRole` derivatives to enforce mentioning specific roles. Raises ------ ValueError If more than 100 unique objects/entities are passed for `role_mentions` or `user_mentions`. 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. .. note:: Mentioning everyone, roles, or users in message edits currently will not send a push notification showing a new mention to people on Discord. It will still highlight in their chat as if they were mentioned, however. .. warning:: If you specify a text `content`, `mentions_everyone`, `mentions_reply`, `user_mentions`, and `role_mentions` will default to `False` as the message will be re-parsed for mentions. This will also occur if only one of the four are specified This is a limitation of Discord's design. If in doubt, specify all four of them each time. 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 `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 `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 `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 `None` will remove all components. components : hikari.undefined.UndefinedNoneOr[typing.Sequence[hikari.api.special_endpoints.ComponentBuilder]] If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing `None` or an empty sequence will remove all components. embed : hikari.undefined.UndefinedNoneOr[hikari.embeds.Embed] If provided, the embed to set on the message. If `hikari.undefined.UNDEFINED`, the previous embed(s) are not changed. If this is `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 `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 : hikari.undefined.UndefinedOr[bool] If provided, whether the message should parse @everyone/@here mentions. user_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]] If provided, and `True`, all user mentions will be detected. If provided, and `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], bool]] If provided, and `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 `hikari.snowflakes.Snowflake`, or `hikari.guilds.PartialRole` derivatives to enforce mentioning specific roles. Returns ------- hikari.messages.Message The edited message. Raises ------ ValueError If more than 100 unique objects/entities are passed for `role_mentions` or `user_mentions`. 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."""
Set of the response types which are valid for deferred messages responses.
This includes the following:
Type-hint of the response types which are valid for deferred messages responses.
The following are valid for this:
View Source
@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."""
Model of the member who triggered an interaction.
Unlike hikari.guilds.Member
, this object comes with an extra InteractionMember.permissions
field.
Variables and properties
The custom banner color for the user, if set else None
.
The official client will decide the default color if not set.
Alias for the accent_color
field.
Return the app that is bound to the user object.
Avatar hash for the user, if they have one, otherwise None
.
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.
When the object was created.
Default avatar URL for this user.
Discriminator for the user.
Display avatar URL for this user.
Return the member's display name.
If the member has a nickname, this will return that nickname. Otherwise, it will return the username instead.
See Also
Member.nickname
Member.username
Flag bits that are set for the user.
Hash of the member's guild avatar guild if set, else None
.
Note: This takes precedence over Member.avatar_hash
.
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.
The ID of the guild this member belongs to.
Return the ID of this entity.
Returns
- Snowflake: The snowflake ID of this object.
Whether this user is a bot account.
True
if this member is deafened in the current voice channel.
This will be hikari.undefined.UNDEFINED
if it's state is unknown.
True
if this member is muted in the current voice channel.
This will be hikari.undefined.UNDEFINED
if it's state is unknown.
Whether the user has passed the guild's membership screening requirements.
This will be hikari.undefined.UNDEFINED
if it's state is unknown.
Whether this user is a system account.
The datetime of when this member joined the guild they belong to.
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.
Example
>>> some_member_without_nickname.mention
'<@123456789123456789>'
>>> some_member_with_nickname.mention
'<@!123456789123456789>'
This member's nickname.
This will be None
if not set.
Permissions the member has in the current channel.
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.
A sequence of the IDs of the member's current roles.
This member's corresponding user object.
Username for the user.
Methods
self,
*,
guild_id: hikari.snowflakes.Snowflake,
is_deaf: Union[bool, hikari.undefined.UndefinedType],
is_mute: Union[bool, hikari.undefined.UndefinedType],
is_pending: Union[bool, hikari.undefined.UndefinedType],
joined_at: datetime.datetime,
nickname: Optional[str],
premium_since: Optional[datetime.datetime],
raw_communication_disabled_until: Optional[datetime.datetime],
role_ids: Sequence[hikari.snowflakes.Snowflake],
user: hikari.users.User,
guild_avatar_hash: Optional[str],
permissions: hikari.permissions.Permissions
):
View Source
def __init__(self, *, guild_id, is_deaf, is_mute, is_pending, joined_at, nickname, premium_since, raw_communication_disabled_until, role_ids, user, guild_avatar_hash, permissions): self.guild_id = guild_id self.is_deaf = is_deaf self.is_mute = is_mute self.is_pending = is_pending self.joined_at = joined_at self.nickname = nickname self.premium_since = premium_since self.raw_communication_disabled_until = raw_communication_disabled_until self.role_ids = role_ids self.user = user self.guild_avatar_hash = guild_avatar_hash self.permissions = permissions
Method generated by attrs for class InteractionMember.
self,
role: Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int],
*,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> None:
View Source
async def add_role( self, role: snowflakes.SnowflakeishOr[PartialRole], *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED ) -> None: """Add a role to the member. Parameters ---------- role : hikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialRole] The role to add. This may be the object or the ID of an existing role. Other Parameters ---------------- reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Raises ------ hikari.errors.ForbiddenError If you are missing the `MANAGE_ROLES` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild, user or role 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. """ await self.user.app.rest.add_role_to_member(self.guild_id, self.user.id, role, reason=reason)
Add a role to the member.
Parameters
- role (hikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialRole]): The role to add. This may be the object or the ID of an existing role.
Other Parameters
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Raises
- hikari.errors.ForbiddenError: If you are missing the
MANAGE_ROLES
permission. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild, user or role 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.
self,
*,
delete_message_days: Union[int, hikari.undefined.UndefinedType] = UNDEFINED,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> None:
View Source
async def ban( self, *, delete_message_days: undefined.UndefinedOr[int] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Ban this member from this guild. Other Parameters ---------------- delete_message_days : hikari.undefined.UndefinedNoneOr[int] If provided, the number of days to delete messages for. This must be between 0 and 7. reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing the `BAN_MEMBERS` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild or user 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. """ await self.user.app.rest.ban_user( self.guild_id, self.user.id, delete_message_days=delete_message_days, reason=reason )
Ban this member from this guild.
Other Parameters
- delete_message_days (hikari.undefined.UndefinedNoneOr[int]): If provided, the number of days to delete messages for. This must be between 0 and 7.
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value.
- hikari.errors.ForbiddenError: If you are missing the
BAN_MEMBERS
permission. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild or user 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.
View Source
def communication_disabled_until(self) -> typing.Optional[datetime.datetime]: """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. """ if ( self.raw_communication_disabled_until is not None and self.raw_communication_disabled_until > time.utc_datetime() ): return self.raw_communication_disabled_until return None
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.
self,
*,
nickname: Union[str, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
nick: Union[str, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
roles: Union[Sequence[Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int]], hikari.undefined.UndefinedType] = UNDEFINED,
mute: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
deaf: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
voice_channel: Union[hikari.channels.GuildVoiceChannel, hikari.snowflakes.Snowflake, int, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
communication_disabled_until: Union[datetime.datetime, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> hikari.guilds.Member:
View Source
async def edit( self, *, nickname: undefined.UndefinedNoneOr[str] = undefined.UNDEFINED, nick: undefined.UndefinedNoneOr[str] = undefined.UNDEFINED, roles: undefined.UndefinedOr[snowflakes.SnowflakeishSequence[PartialRole]] = undefined.UNDEFINED, mute: undefined.UndefinedOr[bool] = undefined.UNDEFINED, deaf: undefined.UndefinedOr[bool] = undefined.UNDEFINED, voice_channel: undefined.UndefinedNoneOr[ snowflakes.SnowflakeishOr[channels_.GuildVoiceChannel] ] = undefined.UNDEFINED, communication_disabled_until: undefined.UndefinedNoneOr[datetime.datetime] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> Member: """Edit the member. Other Parameters ---------------- nickname : hikari.undefined.UndefinedNoneOr[str] If provided, the new nick for the member. If `None`, will remove the members nick. Requires the `MANAGE_NICKNAMES` permission. nick : hikari.undefined.UndefinedNoneOr[str] Deprecated alias for `nickname`. roles : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole]] If provided, the new roles for the member. Requires the `MANAGE_ROLES` permission. mute : hikari.undefined.UndefinedOr[bool] If provided, the new server mute state for the member. Requires the `MUTE_MEMBERS` permission. deaf : hikari.undefined.UndefinedOr[bool] If provided, the new server deaf state for the member. Requires the `DEAFEN_MEMBERS` permission. voice_channel : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.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 : hikari.undefined.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 : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Returns ------- hikari.guilds.Member Object of the member that was updated. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing a permission to do an action. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild or the user 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. """ if nick is not undefined.UNDEFINED: deprecation.warn_deprecated("nick", "Use 'nickname' argument instead") nickname = nick return await self.user.app.rest.edit_member( self.guild_id, self.user.id, nickname=nickname, roles=roles, mute=mute, deaf=deaf, voice_channel=voice_channel, communication_disabled_until=communication_disabled_until, reason=reason, )
Edit the member.
Other Parameters
nickname (hikari.undefined.UndefinedNoneOr[str]): If provided, the new nick for the member. If
None
, will remove the members nick.Requires the
MANAGE_NICKNAMES
permission.- nick (hikari.undefined.UndefinedNoneOr[str]): Deprecated alias for
nickname
. roles (hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole]]): If provided, the new roles for the member.
Requires the
MANAGE_ROLES
permission.mute (hikari.undefined.UndefinedOr[bool]): If provided, the new server mute state for the member.
Requires the
MUTE_MEMBERS
permission.deaf (hikari.undefined.UndefinedOr[bool]): If provided, the new server deaf state for the member.
Requires the
DEAFEN_MEMBERS
permission.voice_channel (hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildVoiceChannel]]]): If provided,
None
or the object or the ID of an existing voice channel to move the member to. IfNone
, will disconnect the member from voice.Requires the
MOVE_MEMBERS
permission and theCONNECT
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 (hikari.undefined.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 (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Returns
- hikari.guilds.Member: Object of the member that was updated.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value.
- hikari.errors.ForbiddenError: If you are missing a permission to do an action.
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild or the user 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.
View Source
async def fetch_dm_channel(self) -> channels_.DMChannel: return await self.user.fetch_dm_channel()
Fetch the DM channel for this user.
Returns
- hikari.channels.DMChannel: The requested channel.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the user 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.
View Source
async def fetch_roles(self) -> typing.Sequence[Role]: """Fetch an up-to-date view of this member's roles from the API. Returns ------- typing.Sequence[hikari.guilds.Role] An up-to-date view of this member's roles. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the member 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. """ fetched_roles = await self.app.rest.fetch_roles(self.guild_id) return [role for role in fetched_roles if role.id in self.role_ids]
Fetch an up-to-date view of this member's roles from the API.
Returns
- typing.Sequence[hikari.guilds.Role]: An up-to-date view of this member's roles.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the member 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.
View Source
async def fetch_self(self) -> Member: """Fetch an up-to-date view of this member from the API. Returns ------- hikari.guilds.Member An up-to-date view of this member. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the member 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. """ return await self.user.app.rest.fetch_member(self.guild_id, self.user.id)
Fetch an up-to-date view of this member from the API.
Returns
- hikari.guilds.Member: An up-to-date view of this member.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the member 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.
View Source
def get_guild(self) -> typing.Optional[Guild]: """Return the guild associated with this member. Returns ------- typing.Optional[hikari.guilds.Guild] The linked guild object or `None` if it's not cached. """ if not isinstance(self.user.app, traits.CacheAware): return None return self.user.app.cache.get_guild(self.guild_id)
Return the guild associated with this member.
Returns
- typing.Optional[hikari.guilds.Guild]: The linked guild object or
None
if it's not cached.
View Source
def get_presence(self) -> typing.Optional[presences_.MemberPresence]: """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. Returns ------- typing.Optional[hikari.presences.MemberPresence] The member presence, or `None` if not known. """ if not isinstance(self.user.app, traits.CacheAware): return None return self.user.app.cache.get_presence(self.guild_id, self.user.id)
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.
Returns
- typing.Optional[hikari.presences.MemberPresence]: The member presence, or
None
if not known.
View Source
def get_roles(self) -> typing.Sequence[Role]: """Return the roles the user has. This will be empty if the roles are missing from the cache. Returns ------- typing.Sequence[hikari.guilds.Role] The roles the users has. """ roles: typing.List[Role] = [] if not isinstance(self.user.app, traits.CacheAware): return roles for role_id in self.role_ids: if role := self.user.app.cache.get_role(role_id): roles.append(role) return roles
Return the roles the user has.
This will be empty if the roles are missing from the cache.
Returns
- typing.Sequence[hikari.guilds.Role]: The roles the users has.
View Source
def get_top_role(self) -> typing.Optional[Role]: """Return the highest role the member has. Returns ------- typing.Optional[hikari.guilds.Role] `None` if the cache is missing the roles information or the highest role the user has. """ roles = sorted(self.get_roles(), key=lambda r: r.position, reverse=True) try: return next(iter(roles)) except StopIteration: return None
Return the highest role the member has.
Returns
- typing.Optional[hikari.guilds.Role]:
None
if the cache is missing the roles information or the highest role the user has.
View Source
async def kick( self, *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Kick this member from this guild. Other Parameters ---------------- reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing the `KICK_MEMBERS` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild or user 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. """ await self.user.app.rest.kick_user(self.guild_id, self.user.id, reason=reason)
Kick this member from this guild.
Other Parameters
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value.
- hikari.errors.ForbiddenError: If you are missing the
KICK_MEMBERS
permission. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild or user 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.
self,
*,
ext: Optional[str] = None,
size: int = 4096
) -> Optional[hikari.files.URL]:
View Source
def make_avatar_url(self, *, ext: typing.Optional[str] = None, size: int = 4096) -> typing.Optional[files.URL]: return self.user.make_avatar_url(ext=ext, size=size)
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.
Parameters
ext (typing.Optional[str]): The ext to use for this URL, defaults to
png
orgif
. Supportspng
,jpeg
,jpg
,webp
andgif
(when animated). Will be ignored for default avatars which can only bepng
.If
None
, then the correct default extension is determined based on whether the icon is animated or not.- size (int): The size to set for the URL, defaults to
4096
. Can be any power of two between 16 and 4096. Will be ignored for default avatars.
Returns
- typing.Optional[hikari.files.URL]: The URL to the avatar, or
None
if not present.
Raises
- ValueError: If
size
is not a power of two or not between 16 and 4096.
self,
*,
ext: Optional[str] = None,
size: int = 4096
) -> Optional[hikari.files.URL]:
View Source
def make_guild_avatar_url( self, *, ext: typing.Optional[str] = None, size: int = 4096 ) -> typing.Optional[files.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. Parameters ---------- ext : typing.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 The size to set for the URL, defaults to `4096`. Can be any power of two between 16 and 4096. Will be ignored for default avatars. Returns ------- typing.Optional[hikari.files.URL] The URL to the avatar, or `None` if not present. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.guild_avatar_hash is None: return None if ext is None: if self.guild_avatar_hash.startswith("a_"): ext = "gif" else: ext = "png" return routes.CDN_MEMBER_AVATAR.compile_to_file( urls.CDN_URL, guild_id=self.guild_id, user_id=self.id, hash=self.guild_avatar_hash, size=size, file_format=ext, )
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.
Parameters
ext (typing.Optional[str]): The ext to use for this URL, defaults to
png
orgif
. Supportspng
,jpeg
,jpg
,webp
andgif
(when animated). Will be ignored for default avatars which can only bepng
.If
None
, then the correct default extension is determined based on whether the icon is animated or not.- size (int): The size to set for the URL, defaults to
4096
. Can be any power of two between 16 and 4096. Will be ignored for default avatars.
Returns
- typing.Optional[hikari.files.URL]: The URL to the avatar, or
None
if not present.
Raises
- ValueError: If
size
is not a power of two or not between 16 and 4096.
self,
role: Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int],
*,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> None:
View Source
async def remove_role( self, role: snowflakes.SnowflakeishOr[PartialRole], *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED ) -> None: """Remove a role from the member. Parameters ---------- role : hikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialRole] The role to remove. This may be the object or the ID of an existing role. Other Parameters ---------------- reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Raises ------ hikari.errors.ForbiddenError If you are missing the `MANAGE_ROLES` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild, user or role 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. """ await self.user.app.rest.remove_role_from_member(self.guild_id, self.user.id, role, reason=reason)
Remove a role from the member.
Parameters
- role (hikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialRole]): The role to remove. This may be the object or the ID of an existing role.
Other Parameters
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Raises
- hikari.errors.ForbiddenError: If you are missing the
MANAGE_ROLES
permission. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild, user or role 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.
self,
content: Union[Any, hikari.undefined.UndefinedType] = UNDEFINED,
*,
attachment: Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO, hikari.undefined.UndefinedType] = UNDEFINED,
attachments: Union[Sequence[Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO]], hikari.undefined.UndefinedType] = UNDEFINED,
component: Union[hikari.api.special_endpoints.ComponentBuilder, hikari.undefined.UndefinedType] = UNDEFINED,
components: Union[Sequence[hikari.api.special_endpoints.ComponentBuilder], hikari.undefined.UndefinedType] = UNDEFINED,
embed: Union[hikari.embeds.Embed, hikari.undefined.UndefinedType] = UNDEFINED,
embeds: Union[Sequence[hikari.embeds.Embed], hikari.undefined.UndefinedType] = UNDEFINED,
tts: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
reply: Union[hikari.messages.PartialMessage, hikari.snowflakes.Snowflake, int, hikari.undefined.UndefinedType] = UNDEFINED,
mentions_everyone: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
mentions_reply: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
user_mentions: Union[Sequence[Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED,
role_mentions: Union[Sequence[Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED
) -> hikari.messages.Message:
View Source
async def send( self, content: undefined.UndefinedOr[typing.Any] = 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, tts: undefined.UndefinedOr[bool] = undefined.UNDEFINED, reply: undefined.UndefinedOr[snowflakes.SnowflakeishOr[messages.PartialMessage]] = undefined.UNDEFINED, mentions_everyone: undefined.UndefinedOr[bool] = undefined.UNDEFINED, mentions_reply: undefined.UndefinedOr[bool] = undefined.UNDEFINED, user_mentions: undefined.UndefinedOr[ typing.Union[snowflakes.SnowflakeishSequence[PartialUser], bool] ] = undefined.UNDEFINED, role_mentions: undefined.UndefinedOr[ typing.Union[snowflakes.SnowflakeishSequence[guilds.PartialRole], bool] ] = undefined.UNDEFINED, ) -> messages.Message: """Send a message to this user in DM's. 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 `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. 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. Other Parameters ---------------- 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 can be passed as many different things, to aid in convenience. - If a `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 `hikari.files.WebResource` such as `hikari.files.URL`, `hikari.messages.Attachment`, `hikari.emojis.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. - If a `hikari.files.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. - If a `hikari.files.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). 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. tts : hikari.undefined.UndefinedOr[bool] If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system. reply : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage]] If provided, the message to reply to. mentions_everyone : hikari.undefined.UndefinedOr[bool] If provided, whether the message should parse @everyone/@here mentions. mentions_reply : hikari.undefined.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 : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]] If provided, and `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 `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], bool]] If provided, and `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 `hikari.snowflakes.Snowflake`, or `hikari.guilds.PartialRole` derivatives to enforce mentioning specific roles. Returns ------- hikari.messages.Message The created message. Raises ------ ValueError If more than 100 unique objects/entities are passed for `role_mentions` or `user_mentions`. TypeError If both `attachment` and `attachments` 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; `reply` not found or not in the same channel; too many components. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `SEND_MESSAGES` in the channel or the person you are trying to message has the DM's disabled. hikari.errors.NotFoundError If the user 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. """ # noqa: E501 - Line too long channel_id = None if isinstance(self.app, traits.CacheAware): channel_id = self.app.cache.get_dm_channel_id(self.id) if channel_id is None: channel_id = (await self.fetch_dm_channel()).id return await self.app.rest.create_message( channel=channel_id, content=content, attachment=attachment, attachments=attachments, component=component, components=components, embed=embed, embeds=embeds, tts=tts, reply=reply, mentions_everyone=mentions_everyone, user_mentions=user_mentions, role_mentions=role_mentions, mentions_reply=mentions_reply, )
Send a message to this user in DM's.
Parameters
content (hikari.undefined.UndefinedOr[typing.Any]): If provided, the message contents. If
hikari.undefined.UNDEFINED
, then nothing will be sent in the content. Any other value here will be cast to astr
.If this is a
hikari.embeds.Embed
and noembed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a
hikari.files.Resource
, then the content is instead treated as an attachment if noattachment
and noattachments
kwargs are provided.
Other Parameters
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 can be passed as many different things, to aid in convenience.
- If a
pathlib.PurePath
orstr
to a valid URL, the resource at the given URL will be streamed to Discord when sending the message. Subclasses ofhikari.files.WebResource
such ashikari.files.URL
,hikari.messages.Attachment
,hikari.emojis.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. - If a
hikari.files.Bytes
is passed, or astr
that contains a valid data URI is passed, then this is uploaded with a randomized file name if not provided. - If a
hikari.files.File
,pathlib.PurePath
orstr
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 ofconcurrent.futures.Executor
that is being used for the application (default is a thread pool which supports this behaviour).
- If a
- 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.
- tts (hikari.undefined.UndefinedOr[bool]): If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system.
- reply (hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage]]): If provided, the message to reply to.
- mentions_everyone (hikari.undefined.UndefinedOr[bool]): If provided, whether the message should parse @everyone/@here mentions.
mentions_reply (hikari.undefined.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 (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]]): If provided, and
True
, all user mentions will be detected. If provided, andFalse
, all user mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.users.PartialUser
derivatives to enforce mentioning specific users. - role_mentions (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], bool]]): If provided, and
True
, all role mentions will be detected. If provided, andFalse
, all role mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.guilds.PartialRole
derivatives to enforce mentioning specific roles.
Returns
- hikari.messages.Message: The created message.
Raises
- ValueError: If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
. - TypeError: If both
attachment
andattachments
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;
reply
not found or not in the same channel; too many components. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. - hikari.errors.NotFoundError: If the user 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.
self,
*,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> None:
View Source
async def unban( self, *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Unban this member from the guild. Other Parameters ---------------- reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing the `BAN_MEMBERS` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild or user 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. """ await self.user.app.rest.unban_user(self.guild_id, self.user.id, reason=reason)
Unban this member from the guild.
Other Parameters
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value.
- hikari.errors.ForbiddenError: If you are missing the
BAN_MEMBERS
permission. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild or user 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.
View Source
@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."""
The type of an interaction.
Variables and properties
An interaction triggered by a user calling an application command.
An interaction triggered by a user typing in a slash command option.
An interaction triggered by a user calling a message component.
the denominator of a rational number in lowest terms
the imaginary part of a complex number
Return the name of the enum member as a str
.
the numerator of a rational number in lowest terms
the real part of a complex number
Return the value of the enum member.
Methods
View Source
def __call__(cls, value: typing.Any) -> typing.Any: """Cast a value to the enum, returning the raw value that was passed if value not found.""" try: return cls._value_to_member_map_[value] except KeyError: # If we can't find the value, just return what got casted in return value
Cast a value to the enum, returning the raw value that was passed if value not found.
Return integer ratio.
Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.
>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
Number of bits necessary to represent self in binary.
>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
Returns self, the complex conjugate of any int.
Return the integer represented by the given array of bytes.
bytes Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol. byteorder The byte order used to represent the integer. If byteorder is 'big', the most significant byte is at the beginning of the byte array. If byteorder is 'little', the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder' as the byte order value. signed Indicates whether two's complement is used to represent the integer.
Return an array of bytes representing an integer.
length Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. byteorder The byte order used to represent the integer. If byteorder is 'big', the most significant byte is at the beginning of the byte array. If byteorder is 'little', the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder' as the byte order value. signed Determines whether two's complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
Set of the response types which are valid for message responses.
This includes the following:
View Source
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[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 `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[int, hikari.messages.MessageFlag, hikari.undefined.UndefinedType] If provided, the message flags this response should have. As of writing the only message flag which can be set here is `hikari.messages.MessageFlag.EPHEMERAL`. tts : hikari.undefined.UndefinedOr[bool] If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system. mentions_everyone : hikari.undefined.UndefinedOr[bool] If provided, whether the message should parse @everyone/@here mentions. user_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]] If provided, and `True`, all user mentions will be detected. If provided, and `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], bool]] If provided, and `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 `hikari.snowflakes.Snowflake`, or `hikari.guilds.PartialRole` derivatives to enforce mentioning specific roles. Raises ------ ValueError If more than 100 unique objects/entities are passed for `role_mentions` or `user_mentions`. 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. .. note:: Mentioning everyone, roles, or users in message edits currently will not send a push notification showing a new mention to people on Discord. It will still highlight in their chat as if they were mentioned, however. .. warning:: If you specify a text `content`, `mentions_everyone`, `mentions_reply`, `user_mentions`, and `role_mentions` will default to `False` as the message will be re-parsed for mentions. This will also occur if only one of the four are specified This is a limitation of Discord's design. If in doubt, specify all four of them each time. 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 `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 `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 `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 `None` will remove all components. components : hikari.undefined.UndefinedNoneOr[typing.Sequence[hikari.api.special_endpoints.ComponentBuilder]] If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing `None` or an empty sequence will remove all components. embed : hikari.undefined.UndefinedNoneOr[hikari.embeds.Embed] If provided, the embed to set on the message. If `hikari.undefined.UNDEFINED`, the previous embed(s) are not changed. If this is `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 `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 : hikari.undefined.UndefinedOr[bool] If provided, whether the message should parse @everyone/@here mentions. user_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]] If provided, and `True`, all user mentions will be detected. If provided, and `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], bool]] If provided, and `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 `hikari.snowflakes.Snowflake`, or `hikari.guilds.PartialRole` derivatives to enforce mentioning specific roles. Returns ------- hikari.messages.Message The edited message. Raises ------ ValueError If more than 100 unique objects/entities are passed for `role_mentions` or `user_mentions`. 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)
Mixin' class for all interaction types which can be responded to with a message.
Variables and properties
The client application that models may use for procedures.
ID of the application this interaction belongs to.
When the object was created.
The interaction's token.
The type of interaction this is.
Version of the interaction system this interaction is under.
ID used to execute this entity as a webhook.
Methods
self,
*,
app: hikari.traits.RESTAware,
id: hikari.snowflakes.Snowflake,
application_id: hikari.snowflakes.Snowflake,
type: Union[hikari.interactions.base_interactions.InteractionType, int],
token: str,
version: int
):
View Source
def __init__(self, *, app, id, application_id, type, token, version): self.app = app self.id = id self.application_id = application_id self.type = type self.token = token self.version = version
Method generated by attrs for class PartialInteraction.
self,
response_type: ~_CommandResponseTypesT,
content: Union[Any, hikari.undefined.UndefinedType] = UNDEFINED,
*,
flags: Union[int, hikari.messages.MessageFlag, hikari.undefined.UndefinedType] = UNDEFINED,
tts: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
attachment: Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO, hikari.undefined.UndefinedType] = UNDEFINED,
attachments: Union[Sequence[Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO]], hikari.undefined.UndefinedType] = UNDEFINED,
component: Union[hikari.api.special_endpoints.ComponentBuilder, hikari.undefined.UndefinedType] = UNDEFINED,
components: Union[Sequence[hikari.api.special_endpoints.ComponentBuilder], hikari.undefined.UndefinedType] = UNDEFINED,
embed: Union[hikari.embeds.Embed, hikari.undefined.UndefinedType] = UNDEFINED,
embeds: Union[Sequence[hikari.embeds.Embed], hikari.undefined.UndefinedType] = UNDEFINED,
mentions_everyone: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
user_mentions: Union[Sequence[Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED,
role_mentions: Union[Sequence[Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED
) -> None:
View Source
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[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 `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[int, hikari.messages.MessageFlag, hikari.undefined.UndefinedType] If provided, the message flags this response should have. As of writing the only message flag which can be set here is `hikari.messages.MessageFlag.EPHEMERAL`. tts : hikari.undefined.UndefinedOr[bool] If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system. mentions_everyone : hikari.undefined.UndefinedOr[bool] If provided, whether the message should parse @everyone/@here mentions. user_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]] If provided, and `True`, all user mentions will be detected. If provided, and `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], bool]] If provided, and `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 `hikari.snowflakes.Snowflake`, or `hikari.guilds.PartialRole` derivatives to enforce mentioning specific roles. Raises ------ ValueError If more than 100 unique objects/entities are passed for `role_mentions` or `user_mentions`. 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, )
Create the initial response for this interaction.
Warning: Calling this on an interaction which already has an initial response will result in this raising a hikari.errors.NotFoundError
. This includes if the REST interaction server has already responded to the request.
Parameters
- response_type (typing.Union[int, CommandResponseTypesT]): The type of interaction response this is.
Other Parameters
content (hikari.undefined.UndefinedOr[typing.Any]): If provided, the message contents. If
hikari.undefined.UNDEFINED
, then nothing will be sent in the content. Any other value here will be cast to astr
.If this is a
hikari.embeds.Embed
and noembed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.- attachment (hikari.undefined.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[int, hikari.messages.MessageFlag, hikari.undefined.UndefinedType]): If provided, the message flags this response should have.
As of writing the only message flag which can be set here is
hikari.messages.MessageFlag.EPHEMERAL
.- tts (hikari.undefined.UndefinedOr[bool]): If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system.
- mentions_everyone (hikari.undefined.UndefinedOr[bool]): If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]]): If provided, and
True
, all user mentions will be detected. If provided, andFalse
, all user mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.users.PartialUser
derivatives to enforce mentioning specific users. - role_mentions (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], bool]]): If provided, and
True
, all role mentions will be detected. If provided, andFalse
, all role mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.guilds.PartialRole
derivatives to enforce mentioning specific roles.
Raises
- ValueError: If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
. - TypeError: If both
embed
andembeds
are specified. - hikari.errors.BadRequestError: This may be raised in several discrete situations, such as messages being empty with no embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; invalid image URLs in embeds.
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the interaction is not found or if the interaction's initial response has already been created.
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
View Source
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)
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.
self,
message: Union[hikari.messages.Message, hikari.snowflakes.Snowflake, int]
) -> None:
View Source
async def delete_message(self, message: snowflakes.SnowflakeishOr[messages_.Message]) -> None: """Delete a given message in a given channel. Parameters ---------- message : hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage] The message to delete. This may be the object or the ID of an existing message. Raises ------ ValueError If `token` is not available. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the webhook 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. """ if self.token is None: raise ValueError("Cannot delete a message using a webhook where we don't know the token") await self.app.rest.delete_webhook_message(self.webhook_id, token=self.token, message=message)
Delete a given message in a given channel.
Parameters
- message (hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage]): The message to delete. This may be the object or the ID of an existing message.
Raises
- ValueError: If
token
is not available. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the webhook 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.
self,
content: Union[Any, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
*,
attachment: Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO, hikari.undefined.UndefinedType] = UNDEFINED,
attachments: Union[Sequence[Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO]], hikari.undefined.UndefinedType] = UNDEFINED,
component: Union[hikari.api.special_endpoints.ComponentBuilder, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
components: Union[Sequence[hikari.api.special_endpoints.ComponentBuilder], hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
embed: Union[hikari.embeds.Embed, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
embeds: Union[Sequence[hikari.embeds.Embed], hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
replace_attachments: bool = False,
mentions_everyone: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
user_mentions: Union[Sequence[Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED,
role_mentions: Union[Sequence[Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED
) -> hikari.messages.Message:
View Source
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. .. note:: Mentioning everyone, roles, or users in message edits currently will not send a push notification showing a new mention to people on Discord. It will still highlight in their chat as if they were mentioned, however. .. warning:: If you specify a text `content`, `mentions_everyone`, `mentions_reply`, `user_mentions`, and `role_mentions` will default to `False` as the message will be re-parsed for mentions. This will also occur if only one of the four are specified This is a limitation of Discord's design. If in doubt, specify all four of them each time. 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 `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 `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 `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 `None` will remove all components. components : hikari.undefined.UndefinedNoneOr[typing.Sequence[hikari.api.special_endpoints.ComponentBuilder]] If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing `None` or an empty sequence will remove all components. embed : hikari.undefined.UndefinedNoneOr[hikari.embeds.Embed] If provided, the embed to set on the message. If `hikari.undefined.UNDEFINED`, the previous embed(s) are not changed. If this is `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 `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 : hikari.undefined.UndefinedOr[bool] If provided, whether the message should parse @everyone/@here mentions. user_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]] If provided, and `True`, all user mentions will be detected. If provided, and `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], bool]] If provided, and `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 `hikari.snowflakes.Snowflake`, or `hikari.guilds.PartialRole` derivatives to enforce mentioning specific roles. Returns ------- hikari.messages.Message The edited message. Raises ------ ValueError If more than 100 unique objects/entities are passed for `role_mentions` or `user_mentions`. 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, )
Edit the initial response of this command interaction.
Note: Mentioning everyone, roles, or users in message edits currently will not send a push notification showing a new mention to people on Discord. It will still highlight in their chat as if they were mentioned, however.
Warning: If you specify a text content
, mentions_everyone
, mentions_reply
, user_mentions
, and role_mentions
will default to False
as the message will be re-parsed for mentions. This will also occur if only one of the four are specified
This is a limitation of Discord's design. If in doubt, specify all four of them each time.
Other Parameters
content (hikari.undefined.UndefinedNoneOr[typing.Any]): If provided, the message contents. If
hikari.undefined.UNDEFINED
, then nothing will be sent in the content. Any other value here will be cast to astr
.If this is a
hikari.embeds.Embed
and neither theembed
orembeds
kwargs are provided or if this is ahikari.files.Resourceish
and neither theattachment
orattachments
kwargs are provided, the values will be overwritten. This allows for simpler syntax when sending an embed or an attachment alone.Likewise, if this is a
hikari.files.Resource
, then the content is instead treated as an attachment if noattachment
and noattachments
kwargs are provided.- attachment (hikari.undefined.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 isNone
, 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 isNone
, then the attachments is removed, if present. Otherwise, the new attachments that were provided will be attached. - component (hikari.undefined.UndefinedNoneOr[hikari.api.special_endpoints.ComponentBuilder]): If provided, builder object of the component to set for this message. This component will replace any previously set components and passing
None
will remove all components. - components (hikari.undefined.UndefinedNoneOr[typing.Sequence[hikari.api.special_endpoints.ComponentBuilder]]): If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing
None
or an empty sequence will remove all components. - embed (hikari.undefined.UndefinedNoneOr[hikari.embeds.Embed]): If provided, the embed to set on the message. If
hikari.undefined.UNDEFINED
, the previous embed(s) are not changed. If this isNone
then any present embeds are removed. Otherwise, the new embed that was provided will be used as the replacement. - embeds (hikari.undefined.UndefinedNoneOr[typing.Sequence[hikari.embeds.Embed]]): If provided, the embeds to set on the message. If
hikari.undefined.UNDEFINED
, the previous embed(s) are not changed. If this isNone
then any present embeds are removed. Otherwise, the new embeds that were provided will be used as the replacement. 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 (hikari.undefined.UndefinedOr[bool]): If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]]): If provided, and
True
, all user mentions will be detected. If provided, andFalse
, all user mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.users.PartialUser
derivatives to enforce mentioning specific users. - role_mentions (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], bool]]): If provided, and
True
, all role mentions will be detected. If provided, andFalse
, all role mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.guilds.PartialRole
derivatives to enforce mentioning specific roles.
Returns
- hikari.messages.Message: The edited message.
Raises
- ValueError: If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
. - TypeError: If both
embed
andembeds
are specified. - hikari.errors.BadRequestError: This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the interaction or the message are not found.
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
self,
message: Union[hikari.messages.Message, hikari.snowflakes.Snowflake, int],
content: Union[Any, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
*,
attachment: Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO, hikari.undefined.UndefinedType] = UNDEFINED,
attachments: Union[Sequence[Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO]], hikari.undefined.UndefinedType] = UNDEFINED,
component: Union[hikari.api.special_endpoints.ComponentBuilder, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
components: Union[Sequence[hikari.api.special_endpoints.ComponentBuilder], hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
embed: Union[hikari.embeds.Embed, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
embeds: Union[Sequence[hikari.embeds.Embed], hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
replace_attachments: bool = False,
mentions_everyone: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
user_mentions: Union[Sequence[Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED,
role_mentions: Union[Sequence[Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED
) -> hikari.messages.Message:
View Source
async def edit_message( self, message: snowflakes.SnowflakeishOr[messages_.Message], 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 a message sent by a webhook. .. note:: Mentioning everyone, roles, or users in message edits currently will not send a push notification showing a new mention to people on Discord. It will still highlight in their chat as if they were mentioned, however. .. warning:: If you specify a text `content`, `mentions_everyone`, `mentions_reply`, `user_mentions`, and `role_mentions` will default to `False` as the message will be re-parsed for mentions. This will also occur if only one of the four are specified This is a limitation of Discord's design. If in doubt, specify all four of them each time. Parameters ---------- message : hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage] The message to delete. This may be the object or the ID of an existing message. 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 `str`. If this is a `hikari.embeds.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 `hikari.files.Resource`, then the content is instead treated as an attachment if no `attachment` and no `attachments` kwargs are provided. Other Parameters ---------------- 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 `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 `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 `None` will remove all components. components : hikari.undefined.UndefinedNoneOr[typing.Sequence[hikari.api.special_endpoints.ComponentBuilder]] If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing `None` or an empty sequence will remove all components. embed : hikari.undefined.UndefinedNoneOr[hikari.embeds.Embed] If provided, the embed to set on the message. If `hikari.undefined.UNDEFINED`, the previous embed(s) are not changed. If this is `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 `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 : hikari.undefined.UndefinedOr[bool] If provided, sanitation for `@everyone` mentions. If `hikari.undefined.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 : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]] If provided, and `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 `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], bool]] If provided, and `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 `hikari.snowflakes.Snowflake`, or `hikari.guilds.PartialRole` derivatives to enforce mentioning specific roles. Returns ------- hikari.messages.Message The edited message. Raises ------ ValueError If more than 100 unique objects/entities are passed for `role_mentions` or `user_mentions` or `token` is not available. TypeError If both `attachment` and `attachments` are specified or 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; too many components. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the webhook 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 if self.token is None: raise ValueError("Cannot edit a message using a webhook where we don't know the token") return await self.app.rest.edit_webhook_message( self.webhook_id, token=self.token, message=message, content=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, )
Edit a message sent by a webhook.
Note: Mentioning everyone, roles, or users in message edits currently will not send a push notification showing a new mention to people on Discord. It will still highlight in their chat as if they were mentioned, however.
Warning: If you specify a text content
, mentions_everyone
, mentions_reply
, user_mentions
, and role_mentions
will default to False
as the message will be re-parsed for mentions. This will also occur if only one of the four are specified
This is a limitation of Discord's design. If in doubt, specify all four of them each time.
Parameters
- message (hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage]): The message to delete. This may be the object or the ID of an existing message.
content (hikari.undefined.UndefinedNoneOr[typing.Any]): If provided, the message contents. If
hikari.undefined.UNDEFINED
, then nothing will be sent in the content. Any other value here will be cast to astr
.If this is a
hikari.embeds.Embed
and noembed
nor noembeds
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
hikari.files.Resource
, then the content is instead treated as an attachment if noattachment
and noattachments
kwargs are provided.
Other Parameters
- 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 isNone
, 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 isNone
, then the attachments is removed, if present. Otherwise, the new attachments that were provided will be attached. - component (hikari.undefined.UndefinedNoneOr[hikari.api.special_endpoints.ComponentBuilder]): If provided, builder object of the component to set for this message. This component will replace any previously set components and passing
None
will remove all components. - components (hikari.undefined.UndefinedNoneOr[typing.Sequence[hikari.api.special_endpoints.ComponentBuilder]]): If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing
None
or an empty sequence will remove all components. - embed (hikari.undefined.UndefinedNoneOr[hikari.embeds.Embed]): If provided, the embed to set on the message. If
hikari.undefined.UNDEFINED
, the previous embed(s) are not changed. If this isNone
then any present embeds are removed. Otherwise, the new embed that was provided will be used as the replacement. - embeds (hikari.undefined.UndefinedNoneOr[typing.Sequence[hikari.embeds.Embed]]): If provided, the embeds to set on the message. If
hikari.undefined.UNDEFINED
, the previous embed(s) are not changed. If this isNone
then any present embeds are removed. Otherwise, the new embeds that were provided will be used as the replacement. 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 (hikari.undefined.UndefinedOr[bool]): If provided, sanitation for
@everyone
mentions. Ifhikari.undefined.UNDEFINED
, then the previous setting is not changed. IfTrue
, then@everyone
/@here
mentions in the message content will show up as mentioning everyone that can view the chat. - user_mentions (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]]): If provided, and
True
, all user mentions will be detected. If provided, andFalse
, all user mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.users.PartialUser
derivatives to enforce mentioning specific users. - role_mentions (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], bool]]): If provided, and
True
, all role mentions will be detected. If provided, andFalse
, all role mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.guilds.PartialRole
derivatives to enforce mentioning specific roles.
Returns
- hikari.messages.Message: The edited message.
Raises
- ValueError: If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
ortoken
is not available. - TypeError: If both
attachment
andattachments
are specified or if bothembed
andembeds
are specified. - hikari.errors.BadRequestError: This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; too many components.
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the webhook 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.
self,
content: Union[Any, hikari.undefined.UndefinedType] = UNDEFINED,
*,
username: Union[str, hikari.undefined.UndefinedType] = UNDEFINED,
avatar_url: Union[hikari.undefined.UndefinedType, str, hikari.files.URL] = UNDEFINED,
tts: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
attachment: Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO, hikari.undefined.UndefinedType] = UNDEFINED,
attachments: Union[Sequence[Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO]], hikari.undefined.UndefinedType] = UNDEFINED,
component: Union[hikari.api.special_endpoints.ComponentBuilder, hikari.undefined.UndefinedType] = UNDEFINED,
components: Union[Sequence[hikari.api.special_endpoints.ComponentBuilder], hikari.undefined.UndefinedType] = UNDEFINED,
embed: Union[hikari.embeds.Embed, hikari.undefined.UndefinedType] = UNDEFINED,
embeds: Union[Sequence[hikari.embeds.Embed], hikari.undefined.UndefinedType] = UNDEFINED,
mentions_everyone: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
user_mentions: Union[Sequence[Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED,
role_mentions: Union[Sequence[Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED,
flags: Union[hikari.undefined.UndefinedType, int, hikari.messages.MessageFlag] = UNDEFINED
) -> hikari.messages.Message:
View Source
async def execute( self, content: undefined.UndefinedOr[typing.Any] = undefined.UNDEFINED, *, username: undefined.UndefinedOr[str] = undefined.UNDEFINED, avatar_url: typing.Union[undefined.UndefinedType, str, files.URL] = 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, flags: typing.Union[undefined.UndefinedType, int, messages_.MessageFlag] = undefined.UNDEFINED, ) -> messages_.Message: """Execute the webhook to create a message. .. warning:: At the time of writing, `username` and `avatar_url` are ignored for interaction webhooks. Additionally, flags this can only be set for interaction webhooks and the only settable flag is EPHEMERAL; this field is just ignored for non-interaction webhooks. 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 `str`. If this is a `hikari.embeds.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 `hikari.files.Resource`, then the content is instead treated as an attachment if no `attachment` and no `attachments` kwargs are provided. Other Parameters ---------------- username : hikari.undefined.UndefinedOr[str] If provided, the username to override the webhook's username for this request. avatar_url : typing.Union[hikari.undefined.UndefinedType, hikari.files.URL, str] If provided, the url of an image to override the webhook's avatar with for this request. tts : hikari.undefined.UndefinedOr[bool] If provided, whether the message will be sent as a TTS message. 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. mentions_everyone : hikari.undefined.UndefinedOr[bool] If provided, whether the message should parse @everyone/@here mentions. user_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]] If provided, and `True`, all mentions will be parsed. If provided, and `False`, no mentions will be parsed. 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], bool]] If provided, and `True`, all mentions will be parsed. If provided, and `False`, no mentions will be parsed. Alternatively this may be a collection of `hikari.snowflakes.Snowflake`, or `hikari.guilds.PartialRole` derivatives to enforce mentioning specific roles. flags : typing.Union[hikari.undefined.UndefinedType, int, hikari.messages.MessageFlag] The flags to set for this webhook message. Returns ------- hikari.messages.Message The created message object. Raises ------ hikari.errors.NotFoundError If the current webhook is not found. hikari.errors.BadRequestError This can be raised if the file is too large; if the embed exceeds the defined limits; if the message content is specified only and empty or greater than `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. hikari.errors.UnauthorizedError If you pass a token that's invalid for the target webhook. ValueError If either `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 If both `attachment` and `attachments`, `component` and `components` or `embed` and `embeds` are specified. """ # noqa: E501 - Line too long if not self.token: raise ValueError("Cannot send a message using a webhook where we don't know the token") return await self.app.rest.execute_webhook( webhook=self.webhook_id, token=self.token, content=content, username=username, avatar_url=avatar_url, tts=tts, attachment=attachment, attachments=attachments, component=component, components=components, embed=embed, embeds=embeds, mentions_everyone=mentions_everyone, user_mentions=user_mentions, role_mentions=role_mentions, flags=flags, )
Execute the webhook to create a message.
Warning: At the time of writing, username
and avatar_url
are ignored for interaction webhooks.
Additionally, flags this can only be set for interaction webhooks and the only settable flag is EPHEMERAL; this field is just ignored for non-interaction webhooks.
Parameters
content (hikari.undefined.UndefinedOr[typing.Any]): If provided, the message contents. If
hikari.undefined.UNDEFINED
, then nothing will be sent in the content. Any other value here will be cast to astr
.If this is a
hikari.embeds.Embed
and noembed
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
hikari.files.Resource
, then the content is instead treated as an attachment if noattachment
and noattachments
kwargs are provided.
Other Parameters
- username (hikari.undefined.UndefinedOr[str]): If provided, the username to override the webhook's username for this request.
- avatar_url (typing.Union[hikari.undefined.UndefinedType, hikari.files.URL, str]): If provided, the url of an image to override the webhook's avatar with for this request.
- tts (hikari.undefined.UndefinedOr[bool]): If provided, whether the message will be sent as a TTS message.
- 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.
- mentions_everyone (hikari.undefined.UndefinedOr[bool]): If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]]): If provided, and
True
, all mentions will be parsed. If provided, andFalse
, no mentions will be parsed. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.users.PartialUser
derivatives to enforce mentioning specific users. - role_mentions (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], bool]]): If provided, and
True
, all mentions will be parsed. If provided, andFalse
, no mentions will be parsed. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.guilds.PartialRole
derivatives to enforce mentioning specific roles. - flags (typing.Union[hikari.undefined.UndefinedType, int, hikari.messages.MessageFlag]): The flags to set for this webhook message.
Returns
- hikari.messages.Message: The created message object.
Raises
- hikari.errors.NotFoundError: If the current webhook is not found.
- hikari.errors.BadRequestError: This can be raised if the file is too large; if the embed exceeds the defined limits; if the message content is specified only and empty or greater than
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. - hikari.errors.UnauthorizedError: If you pass a token that's invalid for the target webhook.
- ValueError: If either
ExecutableWebhook.token
isNone
or more than 100 unique objects/entities are passed forrole_mentions
oruser_mentions or if
token` is not available. - TypeError: If both
attachment
andattachments
,component
andcomponents
orembed
andembeds
are specified.
View Source
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)
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.
self,
message: Union[hikari.messages.Message, hikari.snowflakes.Snowflake, int]
) -> hikari.messages.Message:
View Source
async def fetch_message(self, message: snowflakes.SnowflakeishOr[messages_.Message]) -> messages_.Message: """Fetch an old message sent by the webhook. Parameters ---------- message : hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage] The message to fetch. This may be the object or the ID of an existing channel. Returns ------- hikari.messages.Message The requested message. Raises ------ ValueError If `token` is not available. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the webhook is not found or the webhook's message wasn't 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. """ if self.token is None: raise ValueError("Cannot fetch a message using a webhook where we don't know the token") return await self.app.rest.fetch_webhook_message(self.webhook_id, token=self.token, message=message)
Fetch an old message sent by the webhook.
Parameters
- message (hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage]): The message to fetch. This may be the object or the ID of an existing channel.
Returns
- hikari.messages.Message: The requested message.
Raises
- ValueError: If
token
is not available. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the webhook is not found or the webhook's message wasn't 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.
Type-hint of the response types which are valid for message responses.
The following are valid for this:
View Source
@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
The base model for all interaction models.
Variables and properties
The client application that models may use for procedures.
ID of the application this interaction belongs to.
When the object was created.
The interaction's token.
The type of interaction this is.
Version of the interaction system this interaction is under.
ID used to execute this entity as a webhook.
Methods
self,
*,
app: hikari.traits.RESTAware,
id: hikari.snowflakes.Snowflake,
application_id: hikari.snowflakes.Snowflake,
type: Union[hikari.interactions.base_interactions.InteractionType, int],
token: str,
version: int
):
View Source
def __init__(self, *, app, id, application_id, type, token, version): self.app = app self.id = id self.application_id = application_id self.type = type self.token = token self.version = version
Method generated by attrs for class PartialInteraction.
self,
message: Union[hikari.messages.Message, hikari.snowflakes.Snowflake, int]
) -> None:
View Source
async def delete_message(self, message: snowflakes.SnowflakeishOr[messages_.Message]) -> None: """Delete a given message in a given channel. Parameters ---------- message : hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage] The message to delete. This may be the object or the ID of an existing message. Raises ------ ValueError If `token` is not available. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the webhook 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. """ if self.token is None: raise ValueError("Cannot delete a message using a webhook where we don't know the token") await self.app.rest.delete_webhook_message(self.webhook_id, token=self.token, message=message)
Delete a given message in a given channel.
Parameters
- message (hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage]): The message to delete. This may be the object or the ID of an existing message.
Raises
- ValueError: If
token
is not available. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the webhook 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.
self,
message: Union[hikari.messages.Message, hikari.snowflakes.Snowflake, int],
content: Union[Any, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
*,
attachment: Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO, hikari.undefined.UndefinedType] = UNDEFINED,
attachments: Union[Sequence[Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO]], hikari.undefined.UndefinedType] = UNDEFINED,
component: Union[hikari.api.special_endpoints.ComponentBuilder, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
components: Union[Sequence[hikari.api.special_endpoints.ComponentBuilder], hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
embed: Union[hikari.embeds.Embed, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
embeds: Union[Sequence[hikari.embeds.Embed], hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
replace_attachments: bool = False,
mentions_everyone: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
user_mentions: Union[Sequence[Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED,
role_mentions: Union[Sequence[Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED
) -> hikari.messages.Message:
View Source
async def edit_message( self, message: snowflakes.SnowflakeishOr[messages_.Message], 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 a message sent by a webhook. .. note:: Mentioning everyone, roles, or users in message edits currently will not send a push notification showing a new mention to people on Discord. It will still highlight in their chat as if they were mentioned, however. .. warning:: If you specify a text `content`, `mentions_everyone`, `mentions_reply`, `user_mentions`, and `role_mentions` will default to `False` as the message will be re-parsed for mentions. This will also occur if only one of the four are specified This is a limitation of Discord's design. If in doubt, specify all four of them each time. Parameters ---------- message : hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage] The message to delete. This may be the object or the ID of an existing message. 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 `str`. If this is a `hikari.embeds.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 `hikari.files.Resource`, then the content is instead treated as an attachment if no `attachment` and no `attachments` kwargs are provided. Other Parameters ---------------- 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 `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 `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 `None` will remove all components. components : hikari.undefined.UndefinedNoneOr[typing.Sequence[hikari.api.special_endpoints.ComponentBuilder]] If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing `None` or an empty sequence will remove all components. embed : hikari.undefined.UndefinedNoneOr[hikari.embeds.Embed] If provided, the embed to set on the message. If `hikari.undefined.UNDEFINED`, the previous embed(s) are not changed. If this is `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 `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 : hikari.undefined.UndefinedOr[bool] If provided, sanitation for `@everyone` mentions. If `hikari.undefined.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 : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]] If provided, and `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 `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], bool]] If provided, and `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 `hikari.snowflakes.Snowflake`, or `hikari.guilds.PartialRole` derivatives to enforce mentioning specific roles. Returns ------- hikari.messages.Message The edited message. Raises ------ ValueError If more than 100 unique objects/entities are passed for `role_mentions` or `user_mentions` or `token` is not available. TypeError If both `attachment` and `attachments` are specified or 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; too many components. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the webhook 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 if self.token is None: raise ValueError("Cannot edit a message using a webhook where we don't know the token") return await self.app.rest.edit_webhook_message( self.webhook_id, token=self.token, message=message, content=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, )
Edit a message sent by a webhook.
Note: Mentioning everyone, roles, or users in message edits currently will not send a push notification showing a new mention to people on Discord. It will still highlight in their chat as if they were mentioned, however.
Warning: If you specify a text content
, mentions_everyone
, mentions_reply
, user_mentions
, and role_mentions
will default to False
as the message will be re-parsed for mentions. This will also occur if only one of the four are specified
This is a limitation of Discord's design. If in doubt, specify all four of them each time.
Parameters
- message (hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage]): The message to delete. This may be the object or the ID of an existing message.
content (hikari.undefined.UndefinedNoneOr[typing.Any]): If provided, the message contents. If
hikari.undefined.UNDEFINED
, then nothing will be sent in the content. Any other value here will be cast to astr
.If this is a
hikari.embeds.Embed
and noembed
nor noembeds
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
hikari.files.Resource
, then the content is instead treated as an attachment if noattachment
and noattachments
kwargs are provided.
Other Parameters
- 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 isNone
, 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 isNone
, then the attachments is removed, if present. Otherwise, the new attachments that were provided will be attached. - component (hikari.undefined.UndefinedNoneOr[hikari.api.special_endpoints.ComponentBuilder]): If provided, builder object of the component to set for this message. This component will replace any previously set components and passing
None
will remove all components. - components (hikari.undefined.UndefinedNoneOr[typing.Sequence[hikari.api.special_endpoints.ComponentBuilder]]): If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing
None
or an empty sequence will remove all components. - embed (hikari.undefined.UndefinedNoneOr[hikari.embeds.Embed]): If provided, the embed to set on the message. If
hikari.undefined.UNDEFINED
, the previous embed(s) are not changed. If this isNone
then any present embeds are removed. Otherwise, the new embed that was provided will be used as the replacement. - embeds (hikari.undefined.UndefinedNoneOr[typing.Sequence[hikari.embeds.Embed]]): If provided, the embeds to set on the message. If
hikari.undefined.UNDEFINED
, the previous embed(s) are not changed. If this isNone
then any present embeds are removed. Otherwise, the new embeds that were provided will be used as the replacement. 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 (hikari.undefined.UndefinedOr[bool]): If provided, sanitation for
@everyone
mentions. Ifhikari.undefined.UNDEFINED
, then the previous setting is not changed. IfTrue
, then@everyone
/@here
mentions in the message content will show up as mentioning everyone that can view the chat. - user_mentions (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]]): If provided, and
True
, all user mentions will be detected. If provided, andFalse
, all user mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.users.PartialUser
derivatives to enforce mentioning specific users. - role_mentions (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], bool]]): If provided, and
True
, all role mentions will be detected. If provided, andFalse
, all role mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.guilds.PartialRole
derivatives to enforce mentioning specific roles.
Returns
- hikari.messages.Message: The edited message.
Raises
- ValueError: If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
ortoken
is not available. - TypeError: If both
attachment
andattachments
are specified or if bothembed
andembeds
are specified. - hikari.errors.BadRequestError: This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; too many components.
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the webhook 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.
self,
content: Union[Any, hikari.undefined.UndefinedType] = UNDEFINED,
*,
username: Union[str, hikari.undefined.UndefinedType] = UNDEFINED,
avatar_url: Union[hikari.undefined.UndefinedType, str, hikari.files.URL] = UNDEFINED,
tts: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
attachment: Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO, hikari.undefined.UndefinedType] = UNDEFINED,
attachments: Union[Sequence[Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO]], hikari.undefined.UndefinedType] = UNDEFINED,
component: Union[hikari.api.special_endpoints.ComponentBuilder, hikari.undefined.UndefinedType] = UNDEFINED,
components: Union[Sequence[hikari.api.special_endpoints.ComponentBuilder], hikari.undefined.UndefinedType] = UNDEFINED,
embed: Union[hikari.embeds.Embed, hikari.undefined.UndefinedType] = UNDEFINED,
embeds: Union[Sequence[hikari.embeds.Embed], hikari.undefined.UndefinedType] = UNDEFINED,
mentions_everyone: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
user_mentions: Union[Sequence[Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED,
role_mentions: Union[Sequence[Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED,
flags: Union[hikari.undefined.UndefinedType, int, hikari.messages.MessageFlag] = UNDEFINED
) -> hikari.messages.Message:
View Source
async def execute( self, content: undefined.UndefinedOr[typing.Any] = undefined.UNDEFINED, *, username: undefined.UndefinedOr[str] = undefined.UNDEFINED, avatar_url: typing.Union[undefined.UndefinedType, str, files.URL] = 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, flags: typing.Union[undefined.UndefinedType, int, messages_.MessageFlag] = undefined.UNDEFINED, ) -> messages_.Message: """Execute the webhook to create a message. .. warning:: At the time of writing, `username` and `avatar_url` are ignored for interaction webhooks. Additionally, flags this can only be set for interaction webhooks and the only settable flag is EPHEMERAL; this field is just ignored for non-interaction webhooks. 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 `str`. If this is a `hikari.embeds.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 `hikari.files.Resource`, then the content is instead treated as an attachment if no `attachment` and no `attachments` kwargs are provided. Other Parameters ---------------- username : hikari.undefined.UndefinedOr[str] If provided, the username to override the webhook's username for this request. avatar_url : typing.Union[hikari.undefined.UndefinedType, hikari.files.URL, str] If provided, the url of an image to override the webhook's avatar with for this request. tts : hikari.undefined.UndefinedOr[bool] If provided, whether the message will be sent as a TTS message. 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. mentions_everyone : hikari.undefined.UndefinedOr[bool] If provided, whether the message should parse @everyone/@here mentions. user_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]] If provided, and `True`, all mentions will be parsed. If provided, and `False`, no mentions will be parsed. 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], bool]] If provided, and `True`, all mentions will be parsed. If provided, and `False`, no mentions will be parsed. Alternatively this may be a collection of `hikari.snowflakes.Snowflake`, or `hikari.guilds.PartialRole` derivatives to enforce mentioning specific roles. flags : typing.Union[hikari.undefined.UndefinedType, int, hikari.messages.MessageFlag] The flags to set for this webhook message. Returns ------- hikari.messages.Message The created message object. Raises ------ hikari.errors.NotFoundError If the current webhook is not found. hikari.errors.BadRequestError This can be raised if the file is too large; if the embed exceeds the defined limits; if the message content is specified only and empty or greater than `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. hikari.errors.UnauthorizedError If you pass a token that's invalid for the target webhook. ValueError If either `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 If both `attachment` and `attachments`, `component` and `components` or `embed` and `embeds` are specified. """ # noqa: E501 - Line too long if not self.token: raise ValueError("Cannot send a message using a webhook where we don't know the token") return await self.app.rest.execute_webhook( webhook=self.webhook_id, token=self.token, content=content, username=username, avatar_url=avatar_url, tts=tts, attachment=attachment, attachments=attachments, component=component, components=components, embed=embed, embeds=embeds, mentions_everyone=mentions_everyone, user_mentions=user_mentions, role_mentions=role_mentions, flags=flags, )
Execute the webhook to create a message.
Warning: At the time of writing, username
and avatar_url
are ignored for interaction webhooks.
Additionally, flags this can only be set for interaction webhooks and the only settable flag is EPHEMERAL; this field is just ignored for non-interaction webhooks.
Parameters
content (hikari.undefined.UndefinedOr[typing.Any]): If provided, the message contents. If
hikari.undefined.UNDEFINED
, then nothing will be sent in the content. Any other value here will be cast to astr
.If this is a
hikari.embeds.Embed
and noembed
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
hikari.files.Resource
, then the content is instead treated as an attachment if noattachment
and noattachments
kwargs are provided.
Other Parameters
- username (hikari.undefined.UndefinedOr[str]): If provided, the username to override the webhook's username for this request.
- avatar_url (typing.Union[hikari.undefined.UndefinedType, hikari.files.URL, str]): If provided, the url of an image to override the webhook's avatar with for this request.
- tts (hikari.undefined.UndefinedOr[bool]): If provided, whether the message will be sent as a TTS message.
- 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.
- mentions_everyone (hikari.undefined.UndefinedOr[bool]): If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]]): If provided, and
True
, all mentions will be parsed. If provided, andFalse
, no mentions will be parsed. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.users.PartialUser
derivatives to enforce mentioning specific users. - role_mentions (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], bool]]): If provided, and
True
, all mentions will be parsed. If provided, andFalse
, no mentions will be parsed. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.guilds.PartialRole
derivatives to enforce mentioning specific roles. - flags (typing.Union[hikari.undefined.UndefinedType, int, hikari.messages.MessageFlag]): The flags to set for this webhook message.
Returns
- hikari.messages.Message: The created message object.
Raises
- hikari.errors.NotFoundError: If the current webhook is not found.
- hikari.errors.BadRequestError: This can be raised if the file is too large; if the embed exceeds the defined limits; if the message content is specified only and empty or greater than
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. - hikari.errors.UnauthorizedError: If you pass a token that's invalid for the target webhook.
- ValueError: If either
ExecutableWebhook.token
isNone
or more than 100 unique objects/entities are passed forrole_mentions
oruser_mentions or if
token` is not available. - TypeError: If both
attachment
andattachments
,component
andcomponents
orembed
andembeds
are specified.
self,
message: Union[hikari.messages.Message, hikari.snowflakes.Snowflake, int]
) -> hikari.messages.Message:
View Source
async def fetch_message(self, message: snowflakes.SnowflakeishOr[messages_.Message]) -> messages_.Message: """Fetch an old message sent by the webhook. Parameters ---------- message : hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage] The message to fetch. This may be the object or the ID of an existing channel. Returns ------- hikari.messages.Message The requested message. Raises ------ ValueError If `token` is not available. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the webhook is not found or the webhook's message wasn't 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. """ if self.token is None: raise ValueError("Cannot fetch a message using a webhook where we don't know the token") return await self.app.rest.fetch_webhook_message(self.webhook_id, token=self.token, message=message)
Fetch an old message sent by the webhook.
Parameters
- message (hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage]): The message to fetch. This may be the object or the ID of an existing channel.
Returns
- hikari.messages.Message: The requested message.
Raises
- ValueError: If
token
is not available. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the webhook is not found or the webhook's message wasn't 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.
View Source
@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` """
The type of an interaction response.
Variables and properties
Respond to an autocomplete interaction with suggested choices.
This is valid for the following interaction types:
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:
Acknowledge an interaction with the intention to edit its message later.
This is valid for the following interaction types:
An immediate message response to an interaction.
An immediate interaction response with instructions on how to update its message.
This is valid for the following interaction types:
the denominator of a rational number in lowest terms
the imaginary part of a complex number
Return the name of the enum member as a str
.
the numerator of a rational number in lowest terms
the real part of a complex number
Return the value of the enum member.
Methods
View Source
def __call__(cls, value: typing.Any) -> typing.Any: """Cast a value to the enum, returning the raw value that was passed if value not found.""" try: return cls._value_to_member_map_[value] except KeyError: # If we can't find the value, just return what got casted in return value
Cast a value to the enum, returning the raw value that was passed if value not found.
Return integer ratio.
Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.
>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
Number of bits necessary to represent self in binary.
>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
Returns self, the complex conjugate of any int.
Return the integer represented by the given array of bytes.
bytes Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol. byteorder The byte order used to represent the integer. If byteorder is 'big', the most significant byte is at the beginning of the byte array. If byteorder is 'little', the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder' as the byte order value. signed Indicates whether two's complement is used to represent the integer.
Return an array of bytes representing an integer.
length Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. byteorder The byte order used to represent the integer. If byteorder is 'big', the most significant byte is at the beginning of the byte array. If byteorder is 'little', the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder' as the byte order value. signed Determines whether two's complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.