Skip to content

hikari.interactions.command_interactions#

Models and enums used for Discord's Slash Commands interaction flow.

COMMAND_RESPONSE_TYPES module-attribute #

CommandResponseTypesT module-attribute #

CommandResponseTypesT = Literal[MESSAGE_CREATE, 4, DEFERRED_MESSAGE_CREATE, 5]

Type-hint of the response types which are valid for a command interaction.

The following types are valid for this:

InteractionChannel module-attribute #

InteractionChannel = InteractionChannel

ResolvedOptionData module-attribute #

ResolvedOptionData = ResolvedOptionData

AutocompleteInteraction #

Bases: BaseCommandInteraction

Represents an autocomplete interaction on Discord.

app class-attribute instance-attribute #

app: RESTAware = field(repr=False, eq=False, metadata={SKIP_DEEP_COPY: True})

Client application that models may use for procedures.

application_id class-attribute instance-attribute #

application_id: Snowflake = field(eq=False, repr=False)

ID of the application this interaction belongs to.

channel_id class-attribute instance-attribute #

channel_id: Snowflake = field(eq=False, hash=False, repr=True)

ID of the channel this command interaction event was triggered in.

command_id class-attribute instance-attribute #

command_id: Snowflake = field(eq=False, hash=False, repr=True)

ID of the command being invoked.

command_name class-attribute instance-attribute #

command_name: str = field(eq=False, hash=False, repr=True)

Name of the command being invoked.

command_type class-attribute instance-attribute #

command_type: Union[CommandType, int] = field(eq=False, hash=False, repr=True)

The type of the command.

created_at property #

created_at: datetime

When the object was created.

guild_id class-attribute instance-attribute #

guild_id: Optional[Snowflake] = field(eq=False, hash=False, repr=True)

ID of the guild this command interaction event was triggered in.

This will be None for command interactions triggered in DMs.

guild_locale class-attribute instance-attribute #

guild_locale: Optional[str] = field(eq=False, hash=False, repr=True)

The preferred language of the guild this command interaction was triggered in.

This will be None for command interactions triggered in DMs.

Note

This value can usually only be changed if [COMMUNITY] is in hikari.guilds.Guild.features for the guild and will otherwise default to en-US.

id class-attribute instance-attribute #

id: Snowflake = field(hash=True, repr=True)

ID of this entity.

locale class-attribute instance-attribute #

locale: str = field(eq=False, hash=False, repr=True)

The selected language of the user who triggered this command interaction.

member class-attribute instance-attribute #

member: Optional[InteractionMember] = field(eq=False, hash=False, repr=True)

The member who triggered this command interaction.

This will be None for command interactions triggered in DMs.

Note

This member object comes with the extra field permissions which contains the member's permissions in the current channel.

options class-attribute instance-attribute #

options: Sequence[AutocompleteInteractionOption] = field(
    eq=False, hash=False, repr=True
)

Parameter values provided by the user invoking this command.

token class-attribute instance-attribute #

token: str = field(eq=False, repr=False)

The interaction's token.

type class-attribute instance-attribute #

type: Union[InteractionType, int] = field(eq=False, repr=True)

The type of interaction this is.

user class-attribute instance-attribute #

user: User = field(eq=False, hash=False, repr=True)

The user who triggered this command interaction.

version class-attribute instance-attribute #

version: int = field(eq=False, repr=True)

Version of the interaction system this interaction is under.

webhook_id property #

webhook_id: Snowflake

ID used to execute this entity as a webhook.

build_response #

Get a message response builder for use in the REST server flow.

Note

For interactions received over the gateway hikari.interactions.command_interactions.AutocompleteInteraction.create_response should be used to set the interaction response.

PARAMETER DESCRIPTION
choices

The choices for the autocomplete.

TYPE: Sequence[AutocompleteChoiceBuilder]

Examples:

    async def handle_autocomplete_interaction(interaction: AutocompleteInteraction) -> InteractionAutocompleteBuilder:
        return (
            interaction
            .build_response(
                [
                    AutocompleteChoiceBuilder(name="foo", value="a"),
                    AutocompleteChoiceBuilder(name="bar", value="b"),
                    AutocompleteChoiceBuilder(name="baz", value="c"),
                ]
            )
        )
RETURNS DESCRIPTION
InteractionAutocompleteBuilder

Interaction autocomplete response builder object.

create_response async #

create_response(choices: Sequence[AutocompleteChoiceBuilder]) -> None

Create a response for this autocomplete interaction.

PARAMETER DESCRIPTION
choices

The choices for the autocomplete.

TYPE: Sequence[AutocompleteChoiceBuilder]

delete_message async #

delete_message(message: SnowflakeishOr[Message]) -> None

Delete a given message in a given channel.

PARAMETER DESCRIPTION
message

The message to delete. This may be the object or the ID of an existing message.

TYPE: SnowflakeishOr[PartialMessage]

RAISES DESCRIPTION
ValueError

If token is not available.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

NotFoundError

If the webhook or the message are not found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

edit_message async #

edit_message(
    message: SnowflakeishOr[Message],
    content: UndefinedNoneOr[Any] = undefined.UNDEFINED,
    *,
    attachment: UndefinedNoneOr[
        Union[Resourceish, Attachment]
    ] = undefined.UNDEFINED,
    attachments: UndefinedNoneOr[
        Sequence[Union[Resourceish, Attachment]]
    ] = undefined.UNDEFINED,
    component: UndefinedNoneOr[ComponentBuilder] = undefined.UNDEFINED,
    components: UndefinedNoneOr[
        Sequence[ComponentBuilder]
    ] = undefined.UNDEFINED,
    embed: UndefinedNoneOr[Embed] = undefined.UNDEFINED,
    embeds: UndefinedNoneOr[Sequence[Embed]] = undefined.UNDEFINED,
    mentions_everyone: UndefinedOr[bool] = undefined.UNDEFINED,
    user_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialUser], bool]
    ] = undefined.UNDEFINED,
    role_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialRole], bool]
    ] = undefined.UNDEFINED
) -> Message

Edit 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.

PARAMETER DESCRIPTION
message

The message to delete. This may be the object or the ID of an existing message.

TYPE: SnowflakeishOr[PartialMessage]

content

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 nor attachments kwargs are provided.

TYPE: UndefinedNoneOr[Any] DEFAULT: UNDEFINED

PARAMETER DESCRIPTION
attachment

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.

TYPE: UndefinedNoneOr[Union[Resourceish, Attachment]]

attachments

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.

TYPE: UndefinedNoneOr[Sequence[Union[Resourceish, Attachment]]]

component

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.

TYPE: UndefinedNoneOr[ComponentBuilder]

components

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.

TYPE: UndefinedNoneOr[Sequence[ComponentBuilder]]

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.

TYPE: UndefinedNoneOr[Embed]

embeds

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.

TYPE: UndefinedNoneOr[Sequence[Embed]]

mentions_everyone

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.

TYPE: UndefinedOr[bool]

user_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]]

role_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]]

RETURNS DESCRIPTION
Message

The edited message.

RAISES DESCRIPTION
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.

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.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

NotFoundError

If the webhook or the message are not found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

execute async #

execute(
    content: UndefinedOr[Any] = undefined.UNDEFINED,
    *,
    username: UndefinedOr[str] = undefined.UNDEFINED,
    avatar_url: Union[UndefinedType, str, URL] = undefined.UNDEFINED,
    tts: UndefinedOr[bool] = undefined.UNDEFINED,
    attachment: UndefinedOr[Resourceish] = undefined.UNDEFINED,
    attachments: UndefinedOr[Sequence[Resourceish]] = undefined.UNDEFINED,
    component: UndefinedOr[ComponentBuilder] = undefined.UNDEFINED,
    components: UndefinedOr[Sequence[ComponentBuilder]] = undefined.UNDEFINED,
    embed: UndefinedOr[Embed] = undefined.UNDEFINED,
    embeds: UndefinedOr[Sequence[Embed]] = undefined.UNDEFINED,
    mentions_everyone: UndefinedOr[bool] = undefined.UNDEFINED,
    user_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialUser], bool]
    ] = undefined.UNDEFINED,
    role_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialRole], bool]
    ] = undefined.UNDEFINED,
    flags: Union[UndefinedType, int, MessageFlag] = undefined.UNDEFINED
) -> Message

Execute the webhook to create a message.

Warning

At the time of writing, username and avatar_url are ignored for interaction webhooks.

Additionally, hikari.messages.MessageFlag.SUPPRESS_EMBEDS, hikari.messages.MessageFlag.SUPPRESS_NOTIFICATIONS and hikari.messages.MessageFlag.EPHEMERAL are the only flags that can be set, with hikari.messages.MessageFlag.EPHEMERAL being limited to interaction webhooks.

PARAMETER DESCRIPTION
content

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 and no embeds kwargs are 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.

TYPE: UndefinedOr[Any] DEFAULT: UNDEFINED

PARAMETER DESCRIPTION
username

If provided, the username to override the webhook's username for this request.

TYPE: UndefinedOr[str]

avatar_url

If provided, the url of an image to override the webhook's avatar with for this request.

TYPE: Union[UndefinedType, URL, str]

tts

If provided, whether the message will be sent as a TTS message.

TYPE: UndefinedOr[bool]

attachment

If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.

TYPE: UndefinedOr[Resourceish]

attachments

If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.

TYPE: UndefinedOr[Sequence[Resourceish]]

component

If provided, builder object of the component to include in this message.

TYPE: UndefinedOr[ComponentBuilder]

components

If provided, a sequence of the component builder objects to include in this message.

TYPE: UndefinedOr[Sequence[ComponentBuilder]]

embed

If provided, the message embed.

TYPE: UndefinedOr[Embed]

embeds

If provided, the message embeds.

TYPE: UndefinedOr[Sequence[Embed]]

mentions_everyone

If provided, whether the message should parse @everyone/@here mentions.

TYPE: UndefinedOr[bool]

user_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]]

role_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]]

flags

The flags to set for this webhook message.

TYPE: Union[UndefinedType, int, MessageFlag]

RETURNS DESCRIPTION
Message

The created message object.

RAISES DESCRIPTION
NotFoundError

If the current webhook is not found.

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.

UnauthorizedError

If you pass a token that's invalid for the target webhook.

ValueError

If token is not available.

TypeError

If both attachment and attachments, component and components or embed and embeds are specified.

fetch_channel async #

fetch_channel() -> TextableChannel

Fetch the guild channel this was triggered in.

RETURNS DESCRIPTION
TextableChannel

The requested partial channel derived object of the channel this was triggered in.

RAISES DESCRIPTION
UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

ForbiddenError

If you are missing the hikari.permissions.Permissions.VIEW_CHANNEL permission in the channel.

NotFoundError

If the channel is not found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

fetch_command async #

fetch_command() -> PartialCommand

Fetch the command which triggered this interaction.

RETURNS DESCRIPTION
PartialCommand

Object of this interaction's command.

RAISES DESCRIPTION
ForbiddenError

If you cannot access the target command.

NotFoundError

If the command isn't found.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

fetch_guild async #

fetch_guild() -> Optional[RESTGuild]

Fetch the guild this interaction happened in.

RETURNS DESCRIPTION
Optional[RESTGuild]

Object of the guild this interaction happened in or None if this occurred within a DM channel.

RAISES DESCRIPTION
ForbiddenError

If you are not part of the guild.

NotFoundError

If the guild is not found.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

fetch_message async #

fetch_message(message: SnowflakeishOr[Message]) -> Message

Fetch an old message sent by the webhook.

PARAMETER DESCRIPTION
message

The message to fetch. This may be the object or the ID of an existing channel.

TYPE: SnowflakeishOr[PartialMessage]

RETURNS DESCRIPTION
Message

The requested message.

RAISES DESCRIPTION
ValueError

If token is not available.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

NotFoundError

If the webhook is not found or the webhook's message wasn't found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

get_channel #

get_channel() -> Optional[TextableGuildChannel]

Get the guild channel this was triggered in from the cache.

Note

This will always return None for interactions triggered in a DM channel.

RETURNS DESCRIPTION
Optional[TextableGuildChannel]

The object of the guild channel that was found in the cache or None.

get_guild #

get_guild() -> Optional[GatewayGuild]

Get the object of this interaction's guild guild from the cache.

RETURNS DESCRIPTION
Optional[GatewayGuild]

The object of the guild if found, else None.

AutocompleteInteractionOption #

Bases: CommandInteractionOption

Represents the options passed for a command autocomplete interaction.

is_focused class-attribute instance-attribute #

is_focused: bool = field(default=False, repr=True)

Whether this option is the currently focused option for autocomplete.

Focused options are not guaranteed to be parsed so the value may be a string even if the option type says otherwise.

name class-attribute instance-attribute #

name: str = field(repr=True)

Name of this option.

options class-attribute instance-attribute #

options: Optional[Sequence[Self]] = field(repr=True)

Options provided for this option.

Either hikari.interactions.command_interactions.CommandInteractionOption.value or hikari.interactions.command_interactions.CommandInteractionOption.options will be provided with value being provided when an option is provided as a parameter with a value and options being provided when an option donates a subcommand or group.

type class-attribute instance-attribute #

type: Union[OptionType, int] = field(repr=True)

Type of this option.

value class-attribute instance-attribute #

value: Union[Snowflake, str, int, float, bool, None] = field(repr=True)

Value provided for this option.

Either hikari.interactions.command_interactions.CommandInteractionOption.value or hikari.interactions.command_interactions.CommandInteractionOption.options will be provided with value being provided when an option is provided as a parameter with a value and options being provided when an option donates a subcommand or group.

BaseCommandInteraction #

Bases: PartialInteraction

Represents a base command interaction on Discord.

May be a command interaction or an autocomplete interaction.

app class-attribute instance-attribute #

app: RESTAware = field(repr=False, eq=False, metadata={SKIP_DEEP_COPY: True})

Client application that models may use for procedures.

application_id class-attribute instance-attribute #

application_id: Snowflake = field(eq=False, repr=False)

ID of the application this interaction belongs to.

channel_id class-attribute instance-attribute #

channel_id: Snowflake = field(eq=False, hash=False, repr=True)

ID of the channel this command interaction event was triggered in.

command_id class-attribute instance-attribute #

command_id: Snowflake = field(eq=False, hash=False, repr=True)

ID of the command being invoked.

command_name class-attribute instance-attribute #

command_name: str = field(eq=False, hash=False, repr=True)

Name of the command being invoked.

command_type class-attribute instance-attribute #

command_type: Union[CommandType, int] = field(eq=False, hash=False, repr=True)

The type of the command.

created_at property #

created_at: datetime

When the object was created.

guild_id class-attribute instance-attribute #

guild_id: Optional[Snowflake] = field(eq=False, hash=False, repr=True)

ID of the guild this command interaction event was triggered in.

This will be None for command interactions triggered in DMs.

guild_locale class-attribute instance-attribute #

guild_locale: Optional[str] = field(eq=False, hash=False, repr=True)

The preferred language of the guild this command interaction was triggered in.

This will be None for command interactions triggered in DMs.

Note

This value can usually only be changed if [COMMUNITY] is in hikari.guilds.Guild.features for the guild and will otherwise default to en-US.

id class-attribute instance-attribute #

id: Snowflake = field(hash=True, repr=True)

ID of this entity.

locale class-attribute instance-attribute #

locale: str = field(eq=False, hash=False, repr=True)

The selected language of the user who triggered this command interaction.

member class-attribute instance-attribute #

member: Optional[InteractionMember] = field(eq=False, hash=False, repr=True)

The member who triggered this command interaction.

This will be None for command interactions triggered in DMs.

Note

This member object comes with the extra field permissions which contains the member's permissions in the current channel.

token class-attribute instance-attribute #

token: str = field(eq=False, repr=False)

The interaction's token.

type class-attribute instance-attribute #

type: Union[InteractionType, int] = field(eq=False, repr=True)

The type of interaction this is.

user class-attribute instance-attribute #

user: User = field(eq=False, hash=False, repr=True)

The user who triggered this command interaction.

version class-attribute instance-attribute #

version: int = field(eq=False, repr=True)

Version of the interaction system this interaction is under.

webhook_id property #

webhook_id: Snowflake

ID used to execute this entity as a webhook.

delete_message async #

delete_message(message: SnowflakeishOr[Message]) -> None

Delete a given message in a given channel.

PARAMETER DESCRIPTION
message

The message to delete. This may be the object or the ID of an existing message.

TYPE: SnowflakeishOr[PartialMessage]

RAISES DESCRIPTION
ValueError

If token is not available.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

NotFoundError

If the webhook or the message are not found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

edit_message async #

edit_message(
    message: SnowflakeishOr[Message],
    content: UndefinedNoneOr[Any] = undefined.UNDEFINED,
    *,
    attachment: UndefinedNoneOr[
        Union[Resourceish, Attachment]
    ] = undefined.UNDEFINED,
    attachments: UndefinedNoneOr[
        Sequence[Union[Resourceish, Attachment]]
    ] = undefined.UNDEFINED,
    component: UndefinedNoneOr[ComponentBuilder] = undefined.UNDEFINED,
    components: UndefinedNoneOr[
        Sequence[ComponentBuilder]
    ] = undefined.UNDEFINED,
    embed: UndefinedNoneOr[Embed] = undefined.UNDEFINED,
    embeds: UndefinedNoneOr[Sequence[Embed]] = undefined.UNDEFINED,
    mentions_everyone: UndefinedOr[bool] = undefined.UNDEFINED,
    user_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialUser], bool]
    ] = undefined.UNDEFINED,
    role_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialRole], bool]
    ] = undefined.UNDEFINED
) -> Message

Edit 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.

PARAMETER DESCRIPTION
message

The message to delete. This may be the object or the ID of an existing message.

TYPE: SnowflakeishOr[PartialMessage]

content

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 nor attachments kwargs are provided.

TYPE: UndefinedNoneOr[Any] DEFAULT: UNDEFINED

PARAMETER DESCRIPTION
attachment

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.

TYPE: UndefinedNoneOr[Union[Resourceish, Attachment]]

attachments

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.

TYPE: UndefinedNoneOr[Sequence[Union[Resourceish, Attachment]]]

component

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.

TYPE: UndefinedNoneOr[ComponentBuilder]

components

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.

TYPE: UndefinedNoneOr[Sequence[ComponentBuilder]]

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.

TYPE: UndefinedNoneOr[Embed]

embeds

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.

TYPE: UndefinedNoneOr[Sequence[Embed]]

mentions_everyone

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.

TYPE: UndefinedOr[bool]

user_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]]

role_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]]

RETURNS DESCRIPTION
Message

The edited message.

RAISES DESCRIPTION
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.

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.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

NotFoundError

If the webhook or the message are not found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

execute async #

execute(
    content: UndefinedOr[Any] = undefined.UNDEFINED,
    *,
    username: UndefinedOr[str] = undefined.UNDEFINED,
    avatar_url: Union[UndefinedType, str, URL] = undefined.UNDEFINED,
    tts: UndefinedOr[bool] = undefined.UNDEFINED,
    attachment: UndefinedOr[Resourceish] = undefined.UNDEFINED,
    attachments: UndefinedOr[Sequence[Resourceish]] = undefined.UNDEFINED,
    component: UndefinedOr[ComponentBuilder] = undefined.UNDEFINED,
    components: UndefinedOr[Sequence[ComponentBuilder]] = undefined.UNDEFINED,
    embed: UndefinedOr[Embed] = undefined.UNDEFINED,
    embeds: UndefinedOr[Sequence[Embed]] = undefined.UNDEFINED,
    mentions_everyone: UndefinedOr[bool] = undefined.UNDEFINED,
    user_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialUser], bool]
    ] = undefined.UNDEFINED,
    role_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialRole], bool]
    ] = undefined.UNDEFINED,
    flags: Union[UndefinedType, int, MessageFlag] = undefined.UNDEFINED
) -> Message

Execute the webhook to create a message.

Warning

At the time of writing, username and avatar_url are ignored for interaction webhooks.

Additionally, hikari.messages.MessageFlag.SUPPRESS_EMBEDS, hikari.messages.MessageFlag.SUPPRESS_NOTIFICATIONS and hikari.messages.MessageFlag.EPHEMERAL are the only flags that can be set, with hikari.messages.MessageFlag.EPHEMERAL being limited to interaction webhooks.

PARAMETER DESCRIPTION
content

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 and no embeds kwargs are 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.

TYPE: UndefinedOr[Any] DEFAULT: UNDEFINED

PARAMETER DESCRIPTION
username

If provided, the username to override the webhook's username for this request.

TYPE: UndefinedOr[str]

avatar_url

If provided, the url of an image to override the webhook's avatar with for this request.

TYPE: Union[UndefinedType, URL, str]

tts

If provided, whether the message will be sent as a TTS message.

TYPE: UndefinedOr[bool]

attachment

If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.

TYPE: UndefinedOr[Resourceish]

attachments

If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.

TYPE: UndefinedOr[Sequence[Resourceish]]

component

If provided, builder object of the component to include in this message.

TYPE: UndefinedOr[ComponentBuilder]

components

If provided, a sequence of the component builder objects to include in this message.

TYPE: UndefinedOr[Sequence[ComponentBuilder]]

embed

If provided, the message embed.

TYPE: UndefinedOr[Embed]

embeds

If provided, the message embeds.

TYPE: UndefinedOr[Sequence[Embed]]

mentions_everyone

If provided, whether the message should parse @everyone/@here mentions.

TYPE: UndefinedOr[bool]

user_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]]

role_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]]

flags

The flags to set for this webhook message.

TYPE: Union[UndefinedType, int, MessageFlag]

RETURNS DESCRIPTION
Message

The created message object.

RAISES DESCRIPTION
NotFoundError

If the current webhook is not found.

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.

UnauthorizedError

If you pass a token that's invalid for the target webhook.

ValueError

If token is not available.

TypeError

If both attachment and attachments, component and components or embed and embeds are specified.

fetch_channel async #

fetch_channel() -> TextableChannel

Fetch the guild channel this was triggered in.

RETURNS DESCRIPTION
TextableChannel

The requested partial channel derived object of the channel this was triggered in.

RAISES DESCRIPTION
UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

ForbiddenError

If you are missing the hikari.permissions.Permissions.VIEW_CHANNEL permission in the channel.

NotFoundError

If the channel is not found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

fetch_command async #

fetch_command() -> PartialCommand

Fetch the command which triggered this interaction.

RETURNS DESCRIPTION
PartialCommand

Object of this interaction's command.

RAISES DESCRIPTION
ForbiddenError

If you cannot access the target command.

NotFoundError

If the command isn't found.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

fetch_guild async #

fetch_guild() -> Optional[RESTGuild]

Fetch the guild this interaction happened in.

RETURNS DESCRIPTION
Optional[RESTGuild]

Object of the guild this interaction happened in or None if this occurred within a DM channel.

RAISES DESCRIPTION
ForbiddenError

If you are not part of the guild.

NotFoundError

If the guild is not found.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

fetch_message async #

fetch_message(message: SnowflakeishOr[Message]) -> Message

Fetch an old message sent by the webhook.

PARAMETER DESCRIPTION
message

The message to fetch. This may be the object or the ID of an existing channel.

TYPE: SnowflakeishOr[PartialMessage]

RETURNS DESCRIPTION
Message

The requested message.

RAISES DESCRIPTION
ValueError

If token is not available.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

NotFoundError

If the webhook is not found or the webhook's message wasn't found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

get_channel #

get_channel() -> Optional[TextableGuildChannel]

Get the guild channel this was triggered in from the cache.

Note

This will always return None for interactions triggered in a DM channel.

RETURNS DESCRIPTION
Optional[TextableGuildChannel]

The object of the guild channel that was found in the cache or None.

get_guild #

get_guild() -> Optional[GatewayGuild]

Get the object of this interaction's guild guild from the cache.

RETURNS DESCRIPTION
Optional[GatewayGuild]

The object of the guild if found, else None.

CommandInteraction #

Bases: BaseCommandInteraction, MessageResponseMixin[CommandResponseTypesT], ModalResponseMixin

Represents a command interaction on Discord.

app class-attribute instance-attribute #

app: RESTAware = field(repr=False, eq=False, metadata={SKIP_DEEP_COPY: True})

Client application that models may use for procedures.

app_permissions class-attribute instance-attribute #

app_permissions: Optional[Permissions] = field(eq=False, hash=False, repr=False)

Permissions the bot has in this interaction's channel if it's in a guild.

application_id class-attribute instance-attribute #

application_id: Snowflake = field(eq=False, repr=False)

ID of the application this interaction belongs to.

channel_id class-attribute instance-attribute #

channel_id: Snowflake = field(eq=False, hash=False, repr=True)

ID of the channel this command interaction event was triggered in.

command_id class-attribute instance-attribute #

command_id: Snowflake = field(eq=False, hash=False, repr=True)

ID of the command being invoked.

command_name class-attribute instance-attribute #

command_name: str = field(eq=False, hash=False, repr=True)

Name of the command being invoked.

command_type class-attribute instance-attribute #

command_type: Union[CommandType, int] = field(eq=False, hash=False, repr=True)

The type of the command.

created_at property #

created_at: datetime

When the object was created.

guild_id class-attribute instance-attribute #

guild_id: Optional[Snowflake] = field(eq=False, hash=False, repr=True)

ID of the guild this command interaction event was triggered in.

This will be None for command interactions triggered in DMs.

guild_locale class-attribute instance-attribute #

guild_locale: Optional[str] = field(eq=False, hash=False, repr=True)

The preferred language of the guild this command interaction was triggered in.

This will be None for command interactions triggered in DMs.

Note

This value can usually only be changed if [COMMUNITY] is in hikari.guilds.Guild.features for the guild and will otherwise default to en-US.

id class-attribute instance-attribute #

id: Snowflake = field(hash=True, repr=True)

ID of this entity.

locale class-attribute instance-attribute #

locale: str = field(eq=False, hash=False, repr=True)

The selected language of the user who triggered this command interaction.

member class-attribute instance-attribute #

member: Optional[InteractionMember] = field(eq=False, hash=False, repr=True)

The member who triggered this command interaction.

This will be None for command interactions triggered in DMs.

Note

This member object comes with the extra field permissions which contains the member's permissions in the current channel.

options class-attribute instance-attribute #

options: Optional[Sequence[CommandInteractionOption]] = field(
    eq=False, hash=False, repr=True
)

Parameter values provided by the user invoking this command.

resolved class-attribute instance-attribute #

resolved: Optional[ResolvedOptionData] = field(eq=False, hash=False, repr=False)

Mappings of the objects resolved for the provided command options.

target_id class-attribute instance-attribute #

target_id: Optional[Snowflake] = field(
    default=None, eq=False, hash=False, repr=True
)

The target of the command. Only available if the command is a context menu command.

token class-attribute instance-attribute #

token: str = field(eq=False, repr=False)

The interaction's token.

type class-attribute instance-attribute #

type: Union[InteractionType, int] = field(eq=False, repr=True)

The type of interaction this is.

user class-attribute instance-attribute #

user: User = field(eq=False, hash=False, repr=True)

The user who triggered this command interaction.

version class-attribute instance-attribute #

version: int = field(eq=False, repr=True)

Version of the interaction system this interaction is under.

webhook_id property #

webhook_id: Snowflake

ID used to execute this entity as a webhook.

build_deferred_response #

build_deferred_response() -> InteractionDeferredBuilder

Get a deferred message response builder for use in the REST server flow.

Note

For interactions received over the gateway hikari.interactions.command_interactions.CommandInteraction.create_initial_response should be used to set the interaction response message.

Note

Unlike hikari.api.special_endpoints.InteractionMessageBuilder, the result of this call can be returned as is without any modifications being made to it.

Examples:

    async def handle_command_interaction(interaction: CommandInteraction) -> InteractionMessageBuilder:
        yield interaction.build_deferred_response()

        await interaction.edit_initial_response("Pong!")
RETURNS DESCRIPTION
InteractionMessageBuilder

Deferred interaction message response builder object.

build_modal_response #

build_modal_response(title: str, custom_id: str) -> InteractionModalBuilder

Create a builder for a modal interaction response.

PARAMETER DESCRIPTION
title

The title that will show up in the modal.

TYPE: str

custom_id

Developer set custom ID used for identifying interactions with this modal.

TYPE: str

RETURNS DESCRIPTION
InteractionModalBuilder

The interaction modal response builder object.

build_response #

build_response() -> InteractionMessageBuilder

Get a message response builder for use in the REST server flow.

Note

For interactions received over the gateway hikari.interactions.command_interactions.CommandInteraction.create_initial_response should be used to set the interaction response message.

Examples:

    async def handle_command_interaction(interaction: CommandInteraction) -> InteractionMessageBuilder:
        return (
            interaction
            .build_response()
            .add_embed(Embed(description="Hi there"))
            .set_content("Konnichiwa")
        )
RETURNS DESCRIPTION
InteractionMessageBuilder

Interaction message response builder object.

create_initial_response async #

create_initial_response(
    response_type: _CommandResponseTypesT,
    content: UndefinedOr[Any] = undefined.UNDEFINED,
    *,
    flags: Union[int, MessageFlag, UndefinedType] = undefined.UNDEFINED,
    tts: UndefinedOr[bool] = undefined.UNDEFINED,
    attachment: UndefinedNoneOr[Resourceish] = undefined.UNDEFINED,
    attachments: UndefinedNoneOr[Sequence[Resourceish]] = undefined.UNDEFINED,
    component: UndefinedNoneOr[ComponentBuilder] = undefined.UNDEFINED,
    components: UndefinedNoneOr[
        Sequence[ComponentBuilder]
    ] = undefined.UNDEFINED,
    embed: UndefinedNoneOr[Embed] = undefined.UNDEFINED,
    embeds: UndefinedNoneOr[Sequence[Embed]] = undefined.UNDEFINED,
    mentions_everyone: UndefinedOr[bool] = undefined.UNDEFINED,
    user_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialUser], bool]
    ] = undefined.UNDEFINED,
    role_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialRole], bool]
    ] = undefined.UNDEFINED
) -> None

Create the initial response for this interaction.

Warning

Calling this on an interaction which already has an initial response will result in this raising a hikari.errors.NotFoundError. This includes if the REST interaction server has already responded to the request.

PARAMETER DESCRIPTION
response_type

The type of interaction response this is.

TYPE: Union[int, CommandResponseTypesT]

PARAMETER DESCRIPTION
content

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.

TYPE: UndefinedOr[Any]

attachment

If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.

TYPE: UndefinedNoneOr[Union[Resourceish, Attachment]]

attachments

If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.

TYPE: UndefinedNoneOr[Sequence[Union[Resourceish, Attachment]]]

component

If provided, builder object of the component to include in this message.

TYPE: UndefinedNoneOr[ComponentBuilder]

components

If provided, a sequence of the component builder objects to include in this message.

TYPE: UndefinedNoneOr[Sequence[ComponentBuilder]]

embed

If provided, the message embed.

TYPE: UndefinedNoneOr[Embed]

embeds

If provided, the message embeds.

TYPE: UndefinedNoneOr[Sequence[Embed]]

flags

If provided, the message flags this response should have.

As of writing the only message flags which can be set here are hikari.messages.MessageFlag.EPHEMERAL, hikari.messages.MessageFlag.SUPPRESS_NOTIFICATIONS and hikari.messages.MessageFlag.SUPPRESS_EMBEDS.

TYPE: Union[int, MessageFlag, UndefinedType]

tts

If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system.

TYPE: UndefinedOr[bool]

mentions_everyone

If provided, whether the message should parse @everyone/@here mentions.

TYPE: UndefinedOr[bool]

user_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]]

role_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]]

RAISES DESCRIPTION
ValueError

If more than 100 unique objects/entities are passed for role_mentions or user_mentions.

TypeError

If both embed and embeds are specified.

BadRequestError

This may be raised in several discrete situations, such as messages being empty with no embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; invalid image URLs in embeds.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

NotFoundError

If the interaction is not found or if the interaction's initial response has already been created.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

create_modal_response async #

create_modal_response(
    title: str,
    custom_id: str,
    component: UndefinedOr[ComponentBuilder] = undefined.UNDEFINED,
    components: UndefinedOr[Sequence[ComponentBuilder]] = undefined.UNDEFINED,
) -> None

Create a response by sending a modal.

PARAMETER DESCRIPTION
title

The title that will show up in the modal.

TYPE: str

custom_id

Developer set custom ID used for identifying interactions with this modal.

TYPE: str

PARAMETER DESCRIPTION
component

A component builder to send in this modal.

TYPE: UndefinedOr[Sequence[ComponentBuilder]]

components

A sequence of component builders to send in this modal.

TYPE: UndefinedOr[Sequence[ComponentBuilder]]

RAISES DESCRIPTION
ValueError

If both component and components are specified or if none are specified.

delete_initial_response async #

delete_initial_response() -> None

Delete the initial response of this interaction.

RAISES DESCRIPTION
UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

NotFoundError

If the interaction or response is not found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

delete_message async #

delete_message(message: SnowflakeishOr[Message]) -> None

Delete a given message in a given channel.

PARAMETER DESCRIPTION
message

The message to delete. This may be the object or the ID of an existing message.

TYPE: SnowflakeishOr[PartialMessage]

RAISES DESCRIPTION
ValueError

If token is not available.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

NotFoundError

If the webhook or the message are not found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

edit_initial_response async #

edit_initial_response(
    content: UndefinedNoneOr[Any] = undefined.UNDEFINED,
    *,
    attachment: UndefinedNoneOr[
        Union[Resourceish, Attachment]
    ] = undefined.UNDEFINED,
    attachments: UndefinedNoneOr[
        Sequence[Union[Resourceish, Attachment]]
    ] = undefined.UNDEFINED,
    component: UndefinedNoneOr[ComponentBuilder] = undefined.UNDEFINED,
    components: UndefinedNoneOr[
        Sequence[ComponentBuilder]
    ] = undefined.UNDEFINED,
    embed: UndefinedNoneOr[Embed] = undefined.UNDEFINED,
    embeds: UndefinedNoneOr[Sequence[Embed]] = undefined.UNDEFINED,
    mentions_everyone: UndefinedOr[bool] = undefined.UNDEFINED,
    user_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialUser], bool]
    ] = undefined.UNDEFINED,
    role_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialRole], bool]
    ] = undefined.UNDEFINED
) -> Message

Edit the initial response of this command interaction.

Note

Mentioning everyone, roles, or users in message edits currently will not send a push notification showing a new mention to people on Discord. It will still highlight in their chat as if they were mentioned, however.

Warning

If you specify a text content, mentions_everyone, mentions_reply, user_mentions, and role_mentions will default to False as the message will be re-parsed for mentions. This will also occur if only one of the four are specified

This is a limitation of Discord's design. If in doubt, specify all four of them each time.

PARAMETER DESCRIPTION
content

If provided, the message contents. If 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.

TYPE: UndefinedNoneOr[Any]

attachment

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.

TYPE: UndefinedNoneOr[Union[Resourceish, Attachment]]

attachments

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.

TYPE: UndefinedNoneOr[Sequence[Union[Resourceish, Attachment]]]

component

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.

TYPE: UndefinedNoneOr[ComponentBuilder]

components

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.

TYPE: UndefinedNoneOr[Sequence[ComponentBuilder]]

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.

TYPE: UndefinedNoneOr[Embed]

embeds

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.

TYPE: UndefinedNoneOr[Sequence[Embed]]

mentions_everyone

If provided, whether the message should parse @everyone/@here mentions.

TYPE: UndefinedOr[bool]

user_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]]

role_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]]

RETURNS DESCRIPTION
Message

The edited message.

RAISES DESCRIPTION
ValueError

If more than 100 unique objects/entities are passed for role_mentions or user_mentions.

TypeError

If both embed and embeds are specified.

BadRequestError

This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

NotFoundError

If the interaction or the message are not found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

edit_message async #

edit_message(
    message: SnowflakeishOr[Message],
    content: UndefinedNoneOr[Any] = undefined.UNDEFINED,
    *,
    attachment: UndefinedNoneOr[
        Union[Resourceish, Attachment]
    ] = undefined.UNDEFINED,
    attachments: UndefinedNoneOr[
        Sequence[Union[Resourceish, Attachment]]
    ] = undefined.UNDEFINED,
    component: UndefinedNoneOr[ComponentBuilder] = undefined.UNDEFINED,
    components: UndefinedNoneOr[
        Sequence[ComponentBuilder]
    ] = undefined.UNDEFINED,
    embed: UndefinedNoneOr[Embed] = undefined.UNDEFINED,
    embeds: UndefinedNoneOr[Sequence[Embed]] = undefined.UNDEFINED,
    mentions_everyone: UndefinedOr[bool] = undefined.UNDEFINED,
    user_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialUser], bool]
    ] = undefined.UNDEFINED,
    role_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialRole], bool]
    ] = undefined.UNDEFINED
) -> Message

Edit 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.

PARAMETER DESCRIPTION
message

The message to delete. This may be the object or the ID of an existing message.

TYPE: SnowflakeishOr[PartialMessage]

content

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 nor attachments kwargs are provided.

TYPE: UndefinedNoneOr[Any] DEFAULT: UNDEFINED

PARAMETER DESCRIPTION
attachment

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.

TYPE: UndefinedNoneOr[Union[Resourceish, Attachment]]

attachments

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.

TYPE: UndefinedNoneOr[Sequence[Union[Resourceish, Attachment]]]

component

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.

TYPE: UndefinedNoneOr[ComponentBuilder]

components

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.

TYPE: UndefinedNoneOr[Sequence[ComponentBuilder]]

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.

TYPE: UndefinedNoneOr[Embed]

embeds

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.

TYPE: UndefinedNoneOr[Sequence[Embed]]

mentions_everyone

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.

TYPE: UndefinedOr[bool]

user_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]]

role_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]]

RETURNS DESCRIPTION
Message

The edited message.

RAISES DESCRIPTION
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.

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.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

NotFoundError

If the webhook or the message are not found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

execute async #

execute(
    content: UndefinedOr[Any] = undefined.UNDEFINED,
    *,
    username: UndefinedOr[str] = undefined.UNDEFINED,
    avatar_url: Union[UndefinedType, str, URL] = undefined.UNDEFINED,
    tts: UndefinedOr[bool] = undefined.UNDEFINED,
    attachment: UndefinedOr[Resourceish] = undefined.UNDEFINED,
    attachments: UndefinedOr[Sequence[Resourceish]] = undefined.UNDEFINED,
    component: UndefinedOr[ComponentBuilder] = undefined.UNDEFINED,
    components: UndefinedOr[Sequence[ComponentBuilder]] = undefined.UNDEFINED,
    embed: UndefinedOr[Embed] = undefined.UNDEFINED,
    embeds: UndefinedOr[Sequence[Embed]] = undefined.UNDEFINED,
    mentions_everyone: UndefinedOr[bool] = undefined.UNDEFINED,
    user_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialUser], bool]
    ] = undefined.UNDEFINED,
    role_mentions: UndefinedOr[
        Union[SnowflakeishSequence[PartialRole], bool]
    ] = undefined.UNDEFINED,
    flags: Union[UndefinedType, int, MessageFlag] = undefined.UNDEFINED
) -> Message

Execute the webhook to create a message.

Warning

At the time of writing, username and avatar_url are ignored for interaction webhooks.

Additionally, hikari.messages.MessageFlag.SUPPRESS_EMBEDS, hikari.messages.MessageFlag.SUPPRESS_NOTIFICATIONS and hikari.messages.MessageFlag.EPHEMERAL are the only flags that can be set, with hikari.messages.MessageFlag.EPHEMERAL being limited to interaction webhooks.

PARAMETER DESCRIPTION
content

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 and no embeds kwargs are 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.

TYPE: UndefinedOr[Any] DEFAULT: UNDEFINED

PARAMETER DESCRIPTION
username

If provided, the username to override the webhook's username for this request.

TYPE: UndefinedOr[str]

avatar_url

If provided, the url of an image to override the webhook's avatar with for this request.

TYPE: Union[UndefinedType, URL, str]

tts

If provided, whether the message will be sent as a TTS message.

TYPE: UndefinedOr[bool]

attachment

If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.

TYPE: UndefinedOr[Resourceish]

attachments

If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.

TYPE: UndefinedOr[Sequence[Resourceish]]

component

If provided, builder object of the component to include in this message.

TYPE: UndefinedOr[ComponentBuilder]

components

If provided, a sequence of the component builder objects to include in this message.

TYPE: UndefinedOr[Sequence[ComponentBuilder]]

embed

If provided, the message embed.

TYPE: UndefinedOr[Embed]

embeds

If provided, the message embeds.

TYPE: UndefinedOr[Sequence[Embed]]

mentions_everyone

If provided, whether the message should parse @everyone/@here mentions.

TYPE: UndefinedOr[bool]

user_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialUser], bool]]

role_mentions

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.

TYPE: UndefinedOr[Union[SnowflakeishSequence[PartialRole], bool]]

flags

The flags to set for this webhook message.

TYPE: Union[UndefinedType, int, MessageFlag]

RETURNS DESCRIPTION
Message

The created message object.

RAISES DESCRIPTION
NotFoundError

If the current webhook is not found.

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.

UnauthorizedError

If you pass a token that's invalid for the target webhook.

ValueError

If token is not available.

TypeError

If both attachment and attachments, component and components or embed and embeds are specified.

fetch_channel async #

fetch_channel() -> TextableChannel

Fetch the guild channel this was triggered in.

RETURNS DESCRIPTION
TextableChannel

The requested partial channel derived object of the channel this was triggered in.

RAISES DESCRIPTION
UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

ForbiddenError

If you are missing the hikari.permissions.Permissions.VIEW_CHANNEL permission in the channel.

NotFoundError

If the channel is not found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

fetch_command async #

fetch_command() -> PartialCommand

Fetch the command which triggered this interaction.

RETURNS DESCRIPTION
PartialCommand

Object of this interaction's command.

RAISES DESCRIPTION
ForbiddenError

If you cannot access the target command.

NotFoundError

If the command isn't found.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

fetch_guild async #

fetch_guild() -> Optional[RESTGuild]

Fetch the guild this interaction happened in.

RETURNS DESCRIPTION
Optional[RESTGuild]

Object of the guild this interaction happened in or None if this occurred within a DM channel.

RAISES DESCRIPTION
ForbiddenError

If you are not part of the guild.

NotFoundError

If the guild is not found.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

fetch_initial_response async #

fetch_initial_response() -> Message

Fetch the initial response of this interaction.

RETURNS DESCRIPTION
Message

Message object of the initial response.

RAISES DESCRIPTION
ForbiddenError

If you cannot access the target interaction.

NotFoundError

If the initial response isn't found.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

fetch_message async #

fetch_message(message: SnowflakeishOr[Message]) -> Message

Fetch an old message sent by the webhook.

PARAMETER DESCRIPTION
message

The message to fetch. This may be the object or the ID of an existing channel.

TYPE: SnowflakeishOr[PartialMessage]

RETURNS DESCRIPTION
Message

The requested message.

RAISES DESCRIPTION
ValueError

If token is not available.

UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

NotFoundError

If the webhook is not found or the webhook's message wasn't found.

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

InternalServerError

If an internal error occurs on Discord while handling the request.

get_channel #

get_channel() -> Optional[TextableGuildChannel]

Get the guild channel this was triggered in from the cache.

Note

This will always return None for interactions triggered in a DM channel.

RETURNS DESCRIPTION
Optional[TextableGuildChannel]

The object of the guild channel that was found in the cache or None.

get_guild #

get_guild() -> Optional[GatewayGuild]

Get the object of this interaction's guild guild from the cache.

RETURNS DESCRIPTION
Optional[GatewayGuild]

The object of the guild if found, else None.

CommandInteractionOption #

Represents the options passed for a command interaction.

name class-attribute instance-attribute #

name: str = field(repr=True)

Name of this option.

options class-attribute instance-attribute #

options: Optional[Sequence[Self]] = field(repr=True)

Options provided for this option.

Either hikari.interactions.command_interactions.CommandInteractionOption.value or hikari.interactions.command_interactions.CommandInteractionOption.options will be provided with value being provided when an option is provided as a parameter with a value and options being provided when an option donates a subcommand or group.

type class-attribute instance-attribute #

type: Union[OptionType, int] = field(repr=True)

Type of this option.

value class-attribute instance-attribute #

value: Union[Snowflake, str, int, float, bool, None] = field(repr=True)

Value provided for this option.

Either hikari.interactions.command_interactions.CommandInteractionOption.value or hikari.interactions.command_interactions.CommandInteractionOption.options will be provided with value being provided when an option is provided as a parameter with a value and options being provided when an option donates a subcommand or group.