Skip to content

hikari.interactions.base_interactions#

Base classes and enums inherited and used throughout the interactions flow.

DEFERRED_RESPONSE_TYPES module-attribute #

Set of the response types which are valid for deferred messages responses.

This includes the following:

DeferredResponseTypesT module-attribute #

DeferredResponseTypesT = Literal[
    DEFERRED_MESSAGE_CREATE, 5, DEFERRED_MESSAGE_UPDATE, 6
]

Type-hint of the response types which are valid for deferred messages responses.

The following are valid for this:

MESSAGE_RESPONSE_TYPES module-attribute #

Set of the response types which are valid for message responses.

This includes the following:

MessageResponseTypesT module-attribute #

MessageResponseTypesT = Literal[MESSAGE_CREATE, 4, MESSAGE_UPDATE, 7]

Type-hint of the response types which are valid for message responses.

The following are valid for this:

InteractionChannel #

Bases: PartialChannel

Represents partial channels returned as resolved entities on interactions.

app class-attribute instance-attribute #

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

Client application that models may use for procedures.

created_at property #

created_at: datetime

When the object was created.

id class-attribute instance-attribute #

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

The ID of this entity.

mention property #

mention: str

Return a raw mention string for the channel.

Note

There are platform specific inconsistencies with mentions of GuildCategories, GroupDMChannels and DMChannels showing the correct name but not being interactable.

RETURNS DESCRIPTION
str

The mention string to use.

name class-attribute instance-attribute #

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

The channel's name. This will be missing for DM channels.

permissions class-attribute instance-attribute #

permissions: Permissions = field(eq=False, hash=False, repr=True)

Permissions the command's executor has in this channel.

type class-attribute instance-attribute #

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

The channel's type.

delete async #

delete() -> PartialChannel

Delete a channel in a guild, or close a DM.

Note

For Public servers, the set 'Rules' or 'Guidelines' channels and the 'Public Server Updates' channel cannot be deleted.

RETURNS DESCRIPTION
PartialChannel

Object of the channel that was deleted.

RAISES DESCRIPTION
UnauthorizedError

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

ForbiddenError

If you are missing the hikari.permissions.Permissions.MANAGE_CHANNELS 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.

InternalServerError

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

InteractionMember #

Bases: Member

Model of the member who triggered an interaction.

Unlike hikari.guilds.Member, this object comes with an extra hikari.interactions.base_interactions.InteractionMember.permissions field.

accent_color property #

accent_color: Optional[Color]

The custom banner color for the user, if set else None.

The official client will decide the default color if not set.

accent_colour property #

accent_colour: Optional[Color]

Alias for the hikari.users.User.accent_color field.

app property #

app: RESTAware

Return the app that is bound to the user object.

avatar_hash property #

avatar_hash: Optional[str]

Avatar hash for the user, if they have one, otherwise None.

avatar_url property #

avatar_url: Optional[URL]

Avatar URL for the user, if they have one set.

May be None if no custom avatar is set. In this case, you should use hikari.User.default_avatar_url instead.

banner_hash property #

banner_hash: Optional[str]

Banner hash for the user, if they have one, otherwise None.

banner_url property #

banner_url: Optional[URL]

Banner URL for the user, if they have one set.

May be None if no custom banner is set.

created_at property #

created_at: datetime

When the object was created.

default_avatar_url property #

default_avatar_url: URL

Default avatar URL for this user.

discriminator property #

discriminator: str

Discriminator for the user.

!!! deprecated 2.0.0.dev120 Discriminators are deprecated and being replaced with "0" by Discord during username migration. This field will be removed after migration is complete. Learn more here: https://dis.gd/usernames

display_avatar_url property #

display_avatar_url: URL

Display avatar URL for this user.

display_name property #

display_name: str

Return the member's display name.

If the member has a nickname, this will return that nickname. If the user has a global name, this will return that global name. If the user has neither, the username will be returned instead.

See Also

flags property #

flags: UserFlag

Flag bits that are set for the user.

global_name property #

global_name: Optional[str]

Global name for the user, if they have one, otherwise None.

guild_avatar_hash class-attribute instance-attribute #

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

Hash of the member's guild avatar guild if set, else None.

Note

This takes precedence over hikari.guilds.Member.avatar_hash.

guild_avatar_url property #

guild_avatar_url: Optional[URL]

Guild Avatar URL for the user, if they have one set.

May be None if no guild avatar is set. In this case, you should use hikari.guilds.Member.avatar_hash or hikari.guilds.Member.default_avatar_url instead.

guild_id class-attribute instance-attribute #

guild_id: Snowflake = field(repr=True)

The ID of the guild this member belongs to.

id property #

ID of this entity.

is_bot property #

is_bot: bool

Whether this user is a bot account.

is_deaf class-attribute instance-attribute #

is_deaf: UndefinedOr[bool] = field(repr=False)

True if this member is deafened in the current voice channel.

This will be hikari.undefined.UNDEFINED if it's state is unknown.

is_mute class-attribute instance-attribute #

is_mute: UndefinedOr[bool] = field(repr=False)

True if this member is muted in the current voice channel.

This will be hikari.undefined.UNDEFINED if it's state is unknown.

is_pending class-attribute instance-attribute #

is_pending: UndefinedOr[bool] = field(repr=False)

Whether the user has passed the guild's membership screening requirements.

This will be hikari.undefined.UNDEFINED if it's state is unknown.

is_system property #

is_system: bool

Whether this user is a system account.

joined_at class-attribute instance-attribute #

joined_at: Optional[datetime] = field(repr=True)

The datetime of when this member joined the guild they belong to.

This will be None for guest members that have been temporarily invited.

mention property #

mention: str

Return a raw mention string for the given user.

Examples:

    >>> some_user.mention
    '<@123456789123456789>'

nickname class-attribute instance-attribute #

nickname: Optional[str] = field(repr=True)

This member's nickname.

This will be None if not set.

permissions class-attribute instance-attribute #

permissions: Permissions = field(eq=False, hash=False, repr=False)

Permissions the member has in the current channel.

premium_since class-attribute instance-attribute #

premium_since: Optional[datetime] = field(repr=False)

The datetime of when this member started "boosting" this guild.

Will be None if the member is not a premium user.

raw_communication_disabled_until class-attribute instance-attribute #

raw_communication_disabled_until: Optional[datetime] = field(repr=False)

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 hikari.guilds.Member.communication_disabled_until method to check if the member is timed out at the time of the call.

role_ids class-attribute instance-attribute #

role_ids: Sequence[Snowflake] = field(repr=False)

A sequence of the IDs of the member's current roles.

user class-attribute instance-attribute #

user: User = field(repr=True)

This member's corresponding user object.

username property #

username: str

Username for the user.

add_role async #

add_role(
    role: SnowflakeishOr[PartialRole],
    *,
    reason: UndefinedOr[str] = undefined.UNDEFINED
) -> None

Add a role to the member.

PARAMETER DESCRIPTION
role

The role to add. This may be the object or the ID of an existing role.

TYPE: SnowflakeishOr[PartialRole]

PARAMETER DESCRIPTION
reason

If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.

TYPE: UndefinedOr[str]

RAISES DESCRIPTION
ForbiddenError

If you are missing the hikari.permissions.Permissions.MANAGE_ROLES permission.

UnauthorizedError

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

NotFoundError

If the guild, user or role 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.

ban async #

ban(
    *,
    delete_message_seconds: UndefinedOr[Intervalish] = undefined.UNDEFINED,
    reason: UndefinedOr[str] = undefined.UNDEFINED
) -> None

Ban this member from this guild.

PARAMETER DESCRIPTION
delete_message_seconds

If provided, the number of seconds to delete messages for. This can be represented as either an int/float between 0 and 604800 (7 days), or a datetime.timedelta object.

TYPE: UndefinedNoneOr[Intervalish]

reason

If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.

TYPE: UndefinedOr[str]

RAISES DESCRIPTION
BadRequestError

If any of the fields that are passed have an invalid value.

ForbiddenError

If you are missing the hikari.permissions.Permissions.BAN_MEMBERS permission.

UnauthorizedError

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

NotFoundError

If the guild or user 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.

communication_disabled_until #

communication_disabled_until() -> Optional[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.

edit async #

edit(
    *,
    nickname: UndefinedNoneOr[str] = undefined.UNDEFINED,
    roles: UndefinedOr[SnowflakeishSequence[PartialRole]] = undefined.UNDEFINED,
    mute: UndefinedOr[bool] = undefined.UNDEFINED,
    deaf: UndefinedOr[bool] = undefined.UNDEFINED,
    voice_channel: UndefinedNoneOr[
        SnowflakeishOr[GuildVoiceChannel]
    ] = undefined.UNDEFINED,
    communication_disabled_until: UndefinedNoneOr[
        datetime
    ] = undefined.UNDEFINED,
    reason: UndefinedOr[str] = undefined.UNDEFINED
) -> Member

Edit the member.

PARAMETER DESCRIPTION
nickname

If provided, the new nick for the member. If None, will remove the members nick.

Requires the hikari.permissions.Permissions.MANAGE_NICKNAMES permission.

TYPE: UndefinedNoneOr[str]

roles

If provided, the new roles for the member.

Requires the hikari.permissions.Permissions.MANAGE_ROLES permission.

TYPE: UndefinedOr[SnowflakeishSequence[PartialRole]]

mute

If provided, the new server mute state for the member.

Requires the hikari.permissions.Permissions.MUTE_MEMBERS permission.

TYPE: UndefinedOr[bool]

deaf

If provided, the new server deaf state for the member.

Requires the hikari.permissions.Permissions.DEAFEN_MEMBERS permission.

TYPE: UndefinedOr[bool]

voice_channel

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 hikari.permissions.Permissions.MOVE_MEMBERS permission and the hikari.permissions.Permissions.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.

TYPE: hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildVoiceChannel]]]

communication_disabled_until

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 hikari.permissions.Permissions.MODERATE_MEMBERS permission.

TYPE: UndefinedNoneOr[datetime]

reason

If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.

TYPE: UndefinedOr[str]

RETURNS DESCRIPTION
Member

Object of the member that was updated.

RAISES DESCRIPTION
BadRequestError

If any of the fields that are passed have an invalid value.

ForbiddenError

If you are missing a permission to do an action.

UnauthorizedError

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

NotFoundError

If the guild or the user 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.

fetch_dm_channel async #

fetch_dm_channel() -> DMChannel

Fetch the DM channel for this user.

RETURNS DESCRIPTION
DMChannel

The requested channel.

RAISES DESCRIPTION
UnauthorizedError

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

NotFoundError

If the user 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.

fetch_roles async #

fetch_roles() -> Sequence[Role]

Fetch an up-to-date view of this member's roles from the API.

RETURNS DESCRIPTION
Sequence[Role]

An up-to-date view of this member's roles.

RAISES DESCRIPTION
UnauthorizedError

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

NotFoundError

If the member 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.

fetch_self async #

fetch_self() -> Member

Fetch an up-to-date view of this member from the API.

RETURNS DESCRIPTION
Member

An up-to-date view of this member.

RAISES DESCRIPTION
UnauthorizedError

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

NotFoundError

If the member 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.

get_guild #

get_guild() -> Optional[Guild]

Return the guild associated with this member.

RETURNS DESCRIPTION
Optional[Guild]

The linked guild object or None if it's not cached.

get_presence #

get_presence() -> Optional[MemberPresence]

Get the cached presence for this member, if known.

Presence info includes user status and activities.

This requires the hikari.intents.Intents.GUILD_PRESENCES intent to be enabled.

RETURNS DESCRIPTION
Optional[MemberPresence]

The member presence, or None if not known.

get_roles #

get_roles() -> Sequence[Role]

Return the roles the user has.

This will be empty if the roles are missing from the cache.

RETURNS DESCRIPTION
Sequence[Role]

The roles the users has.

get_top_role #

get_top_role() -> Optional[Role]

Return the highest role the member has.

RETURNS DESCRIPTION
Optional[Role]

None if the cache is missing the roles information or the highest role the user has.

kick async #

kick(*, reason: UndefinedOr[str] = undefined.UNDEFINED) -> None

Kick this member from this guild.

PARAMETER DESCRIPTION
reason

If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.

TYPE: UndefinedOr[str]

RAISES DESCRIPTION
BadRequestError

If any of the fields that are passed have an invalid value.

ForbiddenError

If you are missing the hikari.permissions.Permissions.KICK_MEMBERS permission.

UnauthorizedError

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

NotFoundError

If the guild or user 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.

make_avatar_url #

make_avatar_url(
    *, ext: Optional[str] = None, size: int = 4096
) -> Optional[URL]

Generate the avatar URL for this user, if set.

If no custom avatar is set, this returns None. You can then use the hikari.User.default_avatar_url attribute instead to fetch the displayed URL.

PARAMETER DESCRIPTION
ext

The ext to use for this URL. 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.

TYPE: Optional[str] DEFAULT: None

size

The size to set for the URL. Can be any power of two between 16 and 4096. Will be ignored for default avatars.

TYPE: int DEFAULT: 4096

RETURNS DESCRIPTION
Optional[URL]

The URL to the avatar, or None if not present.

RAISES DESCRIPTION
ValueError

If size is not a power of two or not between 16 and 4096.

make_banner_url #

make_banner_url(
    *, ext: Optional[str] = None, size: int = 4096
) -> Optional[URL]

Generate the banner URL for this user, if set.

If no custom banner is set, this returns None.

PARAMETER DESCRIPTION
ext

The ext to use for this URL. Supports png, jpeg, jpg, webp and gif (when animated).

If None, then the correct default extension is determined based on whether the banner is animated or not.

TYPE: Optional[str] DEFAULT: None

size

The size to set for the URL. Can be any power of two between 16 and 4096.

TYPE: int DEFAULT: 4096

RETURNS DESCRIPTION
Optional[URL]

The URL to the banner, or None if not present.

RAISES DESCRIPTION
ValueError

If size is not a power of two or not between 16 and 4096.

make_guild_avatar_url #

make_guild_avatar_url(
    *, ext: Optional[str] = None, size: int = 4096
) -> Optional[URL]

Generate the guild specific avatar url for this member, if set.

If no guild avatar is set, this returns None.

PARAMETER DESCRIPTION
ext

The ext to use for this URL. 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.

TYPE: Optional[str] DEFAULT: None

size

The size to set for the URL. Can be any power of two between 16 and 4096. Will be ignored for default avatars.

TYPE: int DEFAULT: 4096

RETURNS DESCRIPTION
Optional[URL]

The URL to the avatar, or None if not present.

RAISES DESCRIPTION
ValueError

If size is not a power of two or not between 16 and 4096.

remove_role async #

remove_role(
    role: SnowflakeishOr[PartialRole],
    *,
    reason: UndefinedOr[str] = undefined.UNDEFINED
) -> None

Remove a role from the member.

PARAMETER DESCRIPTION
role

The role to remove. This may be the object or the ID of an existing role.

TYPE: SnowflakeishOr[PartialRole]

PARAMETER DESCRIPTION
reason

If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.

TYPE: UndefinedOr[str]

RAISES DESCRIPTION
ForbiddenError

If you are missing the hikari.permissions.Permissions.MANAGE_ROLES permission.

UnauthorizedError

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

NotFoundError

If the guild, user or role 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.

send async #

send(
    content: UndefinedOr[Any] = 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,
    tts: UndefinedOr[bool] = undefined.UNDEFINED,
    reply: UndefinedOr[SnowflakeishOr[PartialMessage]] = undefined.UNDEFINED,
    reply_must_exist: UndefinedOr[bool] = undefined.UNDEFINED,
    mentions_everyone: UndefinedOr[bool] = undefined.UNDEFINED,
    mentions_reply: 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

Send a message to this user in DM's.

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.

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
attachment

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.

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]]

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]

reply

If provided, the message to reply to.

TYPE: UndefinedOr[SnowflakeishOr[PartialMessage]]

reply_must_exist

If provided, whether to error if the message being replied to does not exist instead of sending as a normal (non-reply) message.

This will not do anything if not being used with reply.

TYPE: UndefinedOr[bool]

mentions_everyone

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

TYPE: UndefinedOr[bool]

mentions_reply

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.

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]]

flags

If provided, optional flags to set on the message. If hikari.undefined.UNDEFINED, then nothing is changed.

Note that some flags may not be able to be set. Currently the only flags that can be set are hikari.messages.MessageFlag.NONE and hikari.messages.MessageFlag.SUPPRESS_EMBEDS.

TYPE: UndefinedOr[MessageFlag]

RETURNS DESCRIPTION
Message

The created message.

RAISES DESCRIPTION
ValueError

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

TypeError

If both attachment and attachments 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; reply not found or not in the same channel; too many components.

UnauthorizedError

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

ForbiddenError

If you are missing the hikari.permissions.Permissions.SEND_MESSAGES in the channel or the person you are trying to message has the DM's disabled.

NotFoundError

If the user 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.

unban async #

unban(*, reason: UndefinedOr[str] = undefined.UNDEFINED) -> None

Unban this member from the guild.

PARAMETER DESCRIPTION
reason

If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.

TYPE: UndefinedOr[str]

RAISES DESCRIPTION
BadRequestError

If any of the fields that are passed have an invalid value.

ForbiddenError

If you are missing the hikari.permissions.Permissions.BAN_MEMBERS permission.

UnauthorizedError

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

NotFoundError

If the guild or user 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.

InteractionType #

Bases: int, Enum

The type of an interaction.

APPLICATION_COMMAND class-attribute instance-attribute #

APPLICATION_COMMAND = 2

An interaction triggered by a user calling an application command.

AUTOCOMPLETE class-attribute instance-attribute #

AUTOCOMPLETE = 4

An interaction triggered by a user typing in a slash command option.

MESSAGE_COMPONENT class-attribute instance-attribute #

MESSAGE_COMPONENT = 3

An interaction triggered by a user calling a message component.

MODAL_SUBMIT class-attribute instance-attribute #

MODAL_SUBMIT = 5

An interaction triggered by a user submitting a modal.

name property #

name: str

Return the name of the enum member as a str.

value property #

value

Return the value of the enum member.

MessageResponseMixin #

Bases: PartialInteraction, Generic[_CommandResponseTypesT]

Mixin' class for all interaction types which can be responded to with a message.

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.

created_at property #

created_at: datetime

When the object was created.

id class-attribute instance-attribute #

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

ID of this entity.

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.

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.

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.

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

ModalResponseMixin #

Bases: PartialInteraction

Mixin' class for all interaction types which can be responded to with a modal.

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.

created_at property #

created_at: datetime

When the object was created.

id class-attribute instance-attribute #

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

ID of this entity.

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.

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

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

PartialInteraction #

Bases: Unique, ExecutableWebhook

The base model for all interaction models.

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.

created_at property #

created_at: datetime

When the object was created.

id class-attribute instance-attribute #

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

ID of this entity.

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.

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

PremiumResponseMixin #

Bases: PartialInteraction

Mixin' class for all interaction types which can be responded to with a premium upsell.

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.

created_at property #

created_at: datetime

When the object was created.

id class-attribute instance-attribute #

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

ID of this entity.

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.

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.

create_premium_required_response async #

create_premium_required_response() -> None

Create a response by sending a premium upsell.

RAISES DESCRIPTION
ForbiddenError

If you cannot access the target interaction.

NotFoundError

If the initial response isn't found.

UnauthorizedError

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

RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than 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_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_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.

ResolvedOptionData #

Represents the resolved objects of entities referenced in a command's options.

attachments class-attribute instance-attribute #

attachments: Mapping[Snowflake, Attachment] = field(repr=False)

Mapping of snowflake IDs to the attachment objects.

channels class-attribute instance-attribute #

channels: Mapping[Snowflake, InteractionChannel] = field(repr=False)

Mapping of snowflake IDs to the resolved option partial channel objects.

members class-attribute instance-attribute #

members: Mapping[Snowflake, InteractionMember] = field(repr=False)

Mapping of snowflake IDs to the resolved option member objects.

messages class-attribute instance-attribute #

messages: Mapping[Snowflake, Message] = field(repr=False)

Mapping of snowflake IDs to the resolved option partial message objects.

roles class-attribute instance-attribute #

roles: Mapping[Snowflake, Role] = field(repr=False)

Mapping of snowflake IDs to the resolved option role objects.

users class-attribute instance-attribute #

users: Mapping[Snowflake, User] = field(repr=False)

Mapping of snowflake IDs to the resolved option user objects.

ResponseType #

Bases: int, Enum

The type of an interaction response.

AUTOCOMPLETE class-attribute instance-attribute #

AUTOCOMPLETE = 8

Respond to an autocomplete interaction with suggested choices.

This is valid for the following interaction types:

DEFERRED_MESSAGE_CREATE class-attribute instance-attribute #

DEFERRED_MESSAGE_CREATE = 5

Acknowledge an interaction with the intention to edit in a message response later.

The user will see a loading state when this type is used until this interaction expires or a message response is edited in over REST.

This is valid for the following interaction types:

DEFERRED_MESSAGE_UPDATE class-attribute instance-attribute #

DEFERRED_MESSAGE_UPDATE = 6

Acknowledge an interaction with the intention to edit its message later.

This is valid for the following interaction types:

MESSAGE_CREATE class-attribute instance-attribute #

MESSAGE_CREATE = 4

MESSAGE_UPDATE class-attribute instance-attribute #

MESSAGE_UPDATE = 7

An immediate interaction response with instructions on how to update its message.

This is valid for the following interaction types:

MODAL class-attribute instance-attribute #

MODAL = 9

An immediate interaction response with instructions to display a modal.

This is valid for the following interaction types:

PREMIUM_REQUIRED class-attribute instance-attribute #

PREMIUM_REQUIRED = 10

An immediate interaction response with a premium upsell button Only available for apps with monetization enabled.

This is valid for the following interaction types:

  • InteractionType.APPLICATION_COMMAND
  • InteractionType.MESSAGE_COMPONENT
  • InteractionType.MODAL_SUBMIT

name property #

name: str

Return the name of the enum member as a str.

value property #

value

Return the value of the enum member.