Skip to content

hikari.messages#

Application and entities that are used to describe messages on Discord.

Attachment #

Bases: Unique, WebResource

Represents a file attached to a message.

You can use this object in the same way as a hikari.files.WebResource, by passing it as an attached file when creating a message, etc.

It can also be used when editing a message to keep a previous attachment.

description class-attribute instance-attribute #

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

The description of the file.

duration class-attribute instance-attribute #

duration: Optional[float] = field(hash=False, eq=False, repr=False)

The duration (in seconds) of the voice message.

filename class-attribute instance-attribute #

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

The filename of the file.

height class-attribute instance-attribute #

height: Optional[int] = field(hash=False, eq=False, repr=False)

The height of the image (if the file is an image).

id class-attribute instance-attribute #

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

The ID of this entity.

is_ephemeral class-attribute instance-attribute #

is_ephemeral: bool = field(hash=False, eq=False, repr=True)

Whether this attachment is ephemeral.

This is a part of the ephemeral message response interactions feature and indicates that the attachment will be removed after a set period of time (but will exist as long as their relevant message exists).

media_type class-attribute instance-attribute #

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

The media type of the file.

proxy_url class-attribute instance-attribute #

proxy_url: str = field(hash=False, eq=False, repr=False)

The proxied URL of file.

size class-attribute instance-attribute #

size: int = field(hash=False, eq=False, repr=True)

The size of the file in bytes.

title class-attribute instance-attribute #

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

The title of the file.

This will be the original filename of the attachment if it contained non-unicode characters.

url class-attribute instance-attribute #

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

The source URL of file.

waveform class-attribute instance-attribute #

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

A base64 encoded representation of the sampled waveform for the voice message.

width class-attribute instance-attribute #

width: Optional[int] = field(hash=False, eq=False, repr=False)

The width of the image (if the file is an image).

Message #

Bases: PartialMessage

Represents a message with all known details.

activity class-attribute instance-attribute #

activity: Optional[MessageActivity] = field(hash=False, eq=False, repr=False)

The message activity.

Note

This will only be provided for messages with rich-presence related chat embeds.

application class-attribute instance-attribute #

application: Optional[MessageApplication] = field(hash=False, eq=False, repr=False)

The message application.

Note

This will only be provided for messages with rich-presence related chat embeds.

application_id class-attribute instance-attribute #

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

ID of the application this message was sent by.

Note

This will only be provided for interaction messages.

attachments class-attribute instance-attribute #

attachments: Sequence[Attachment] = field(hash=False, eq=False, repr=False)

The message attachments.

author class-attribute instance-attribute #

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

The author of this message.

components class-attribute instance-attribute #

components: Sequence[MessageActionRowComponent] = field(hash=False, eq=False, repr=False)

Sequence of the components attached to this message.

content class-attribute instance-attribute #

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

The content of the message.

edited_timestamp class-attribute instance-attribute #

edited_timestamp: Optional[datetime] = field(hash=False, eq=False, repr=False)

The timestamp that the message was last edited at.

Will be None if it wasn't ever edited.

embeds class-attribute instance-attribute #

embeds: Sequence[Embed] = field(hash=False, eq=False, repr=False)

The message embeds.

flags class-attribute instance-attribute #

flags: MessageFlag = field(hash=False, eq=False, repr=True)

The message flags.

interaction class-attribute instance-attribute #

interaction: Optional[MessageInteraction] = field(hash=False, eq=False, repr=False)

Information about the interaction this message was created by.

is_pinned class-attribute instance-attribute #

is_pinned: bool = field(hash=False, eq=False, repr=False)

Whether the message is pinned.

is_tts class-attribute instance-attribute #

is_tts: bool = field(hash=False, eq=False, repr=False)

Whether the message is a TTS message.

member class-attribute instance-attribute #

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

The member properties for the message's author.

message_reference class-attribute instance-attribute #

message_reference: Optional[MessageReference] = field(hash=False, eq=False, repr=False)

The message reference data.

nonce class-attribute instance-attribute #

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

The message nonce. This is a string used for validating a message was sent.

reactions class-attribute instance-attribute #

reactions: Sequence[Reaction] = field(hash=False, eq=False, repr=False)

The message reactions.

referenced_message class-attribute instance-attribute #

referenced_message: Optional[PartialMessage] = field(hash=False, eq=False, repr=False)

The message that was replied to.

If type is hikari.messages.MessageType.REPLY and None, the message was deleted.

stickers class-attribute instance-attribute #

stickers: Sequence[PartialSticker] = field(hash=False, eq=False, repr=False)

The stickers sent with this message.

thread class-attribute instance-attribute #

thread: Optional[GuildThreadChannel] = field(hash=False, eq=False, repr=False)

The thread that was started from this message.

Will be None if the message was not used to start a thread.

timestamp class-attribute instance-attribute #

timestamp: datetime = field(hash=False, eq=False, repr=False)

The timestamp that the message was sent at.

type class-attribute instance-attribute #

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

The message type.

webhook_id class-attribute instance-attribute #

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

If the message was generated by a webhook, the webhook's id.

MessageActivity #

Represents the activity of a rich presence-enabled message.

party_id class-attribute instance-attribute #

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

The party ID of the message activity.

type class-attribute instance-attribute #

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

The type of message activity.

MessageActivityType #

Bases: int, Enum

The type of a rich presence message activity.

JOIN class-attribute instance-attribute #

JOIN = 1

Join an activity.

JOIN_REQUEST class-attribute instance-attribute #

JOIN_REQUEST = 5

Request to join an activity.

LISTEN class-attribute instance-attribute #

LISTEN = 3

Listening to something.

NONE class-attribute instance-attribute #

NONE = 0

No activity.

SPECTATE class-attribute instance-attribute #

SPECTATE = 2

Spectating something.

MessageApplication #

Bases: PartialApplication

The representation of an application used in messages.

cover_image_hash class-attribute instance-attribute #

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

The CDN's hash of this application's default rich presence invite cover image.

cover_image_url property #

cover_image_url: Optional[URL]

Rich presence cover image URL for this application, if set.

make_cover_image_url #

make_cover_image_url(*, ext: str = 'png', size: int = 4096) -> Optional[URL]

Generate the rich presence cover image URL for this application, if set.

PARAMETER DESCRIPTION
ext

The extension to use for this URL. supports png, jpeg, jpg and webp.

TYPE: str DEFAULT: 'png'

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, or None if no cover image exists.

RAISES DESCRIPTION
ValueError

If the size is not an integer power of 2 between 16 and 4096 (inclusive).

MessageFlag #

Bases: Flag

Additional flags for message options.

CROSSPOSTED class-attribute instance-attribute #

CROSSPOSTED = 1 << 0

This message has been published to subscribed channels via channel following.

EPHEMERAL class-attribute instance-attribute #

EPHEMERAL = 1 << 6

This message is only visible to the user that invoked the interaction.

FAILED_TO_MENTION_SOME_ROLES_IN_THREAD class-attribute instance-attribute #

FAILED_TO_MENTION_SOME_ROLES_IN_THREAD = 1 << 8

This message failed to mention some roles and add their mentions to the thread.

IS_CROSSPOST class-attribute instance-attribute #

IS_CROSSPOST = 1 << 1

This message originated from a message in another channel via channel following.

IS_VOICE_MESSAGE class-attribute instance-attribute #

IS_VOICE_MESSAGE = 1 << 13

This message is a voice message.

LOADING class-attribute instance-attribute #

LOADING = 1 << 7

This message symbolizes that the interaction is 'thinking'.

NONE class-attribute instance-attribute #

NONE = 0

None.

SOURCE_MESSAGE_DELETED class-attribute instance-attribute #

SOURCE_MESSAGE_DELETED = 1 << 3

The message this crosspost originated from was deleted via channel following.

SUPPRESS_EMBEDS class-attribute instance-attribute #

SUPPRESS_EMBEDS = 1 << 2

Any embeds on this message should be omitted when serializing the message.

SUPPRESS_NOTIFICATIONS class-attribute instance-attribute #

SUPPRESS_NOTIFICATIONS = 1 << 12

This message will not trigger push and desktop notifications.

URGENT class-attribute instance-attribute #

URGENT = 1 << 4

This message came from the urgent message system.

MessageInteraction #

Representation of information provided for a message from an interaction.

id class-attribute instance-attribute #

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

ID of the interaction this message was sent by.

name class-attribute instance-attribute #

name: str = field(eq=False, repr=True)

Name of the application command the interaction is tied to.

type class-attribute instance-attribute #

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

The type of interaction this message was created by.

user class-attribute instance-attribute #

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

Object of the user who invoked this interaction.

MessageReference #

Represents information about a referenced message.

This will be included in crossposted messages, channel follow add message, pin add messages and replies.

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.

channel_id class-attribute instance-attribute #

channel_id: Snowflake = field(repr=True)

The ID of the channel that the original message originated from.

channel_link: str

Generate a jump link to the channel the referenced message was sent in.

This will always be a valid link.

guild_id class-attribute instance-attribute #

guild_id: Optional[Snowflake] = field(repr=True)

The ID of the guild that the message originated from.

This will be None when the original message is not from a guild.

id class-attribute instance-attribute #

id: Optional[Snowflake] = field(repr=True)

The ID of the original message.

This will be None for channel follow add messages. This may point to a deleted message.

message_link: Optional[str]

Generate a jump link to the referenced message.

This will be None for channel follow add messages. This may point to a deleted message.

MessageType #

Bases: int, Enum

The type of a message.

CALL class-attribute instance-attribute #

CALL = 3

A message to denote a VoIP call.

CHANNEL_FOLLOW_ADD class-attribute instance-attribute #

CHANNEL_FOLLOW_ADD = 12

Channel follow add.

CHANNEL_ICON_CHANGE class-attribute instance-attribute #

CHANNEL_ICON_CHANGE = 5

A message to denote that the icon of a channel changed.

CHANNEL_NAME_CHANGE class-attribute instance-attribute #

CHANNEL_NAME_CHANGE = 4

A message to denote that the name of a channel changed.

CHANNEL_PINNED_MESSAGE class-attribute instance-attribute #

CHANNEL_PINNED_MESSAGE = 6

A message to denote that a message was pinned.

CHAT_INPUT class-attribute instance-attribute #

CHAT_INPUT = 20

A message sent to indicate a chat input application command has been executed.

CONTEXT_MENU_COMMAND class-attribute instance-attribute #

CONTEXT_MENU_COMMAND = 23

A message sent to indicate a context menu has been executed.

DEFAULT class-attribute instance-attribute #

DEFAULT = 0

A normal message.

GUILD_DISCOVERY_DISQUALIFIED class-attribute instance-attribute #

GUILD_DISCOVERY_DISQUALIFIED = 14

A message to indicate that a guild has been disqualified from discovery.

GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING class-attribute instance-attribute #

GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING = 17

A message to indicate the final warning before removal from discovery.

GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING class-attribute instance-attribute #

GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING = 16

A message to indicate that the grace period before removal from discovery has started.

GUILD_DISCOVERY_REQUALIFIED class-attribute instance-attribute #

GUILD_DISCOVERY_REQUALIFIED = 15

A message to indicate that a guild has re-qualified for discovery.

GUILD_INVITE_REMINDER class-attribute instance-attribute #

GUILD_INVITE_REMINDER = 22

A message sent to remind to invite people to the guild.

GUILD_MEMBER_JOIN class-attribute instance-attribute #

GUILD_MEMBER_JOIN = 7

A message to denote that a member joined the guild.

RECIPIENT_ADD class-attribute instance-attribute #

RECIPIENT_ADD = 1

A message to denote a new recipient in a group.

RECIPIENT_REMOVE class-attribute instance-attribute #

RECIPIENT_REMOVE = 2

A message to denote that a recipient left the group.

REPLY class-attribute instance-attribute #

REPLY = 19

A message that replies to another message.

ROLE_SUBSCRIPTION_PURCHASE class-attribute instance-attribute #

ROLE_SUBSCRIPTION_PURCHASE = 25

A message sent to indicate a role subscription has been purchased.

USER_PREMIUM_GUILD_SUBSCRIPTION class-attribute instance-attribute #

USER_PREMIUM_GUILD_SUBSCRIPTION = 8

A message to denote a Nitro subscription.

USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1 class-attribute instance-attribute #

USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1 = 9

A message to denote a tier 1 Nitro subscription.

USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 class-attribute instance-attribute #

USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 = 10

A message to denote a tier 2 Nitro subscription.

USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 class-attribute instance-attribute #

USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = 11

A message to denote a tier 3 Nitro subscription.

PartialMessage #

Bases: Unique

A message representation containing partially populated information.

This contains arbitrary fields that may be updated in a hikari.events.message_events.MessageUpdateEvent, but for all other purposes should be treated as being optionally specified.

Warning

All fields on this model except id and channel_id may be set to hikari.undefined.UNDEFINED if we have not received information about their state from Discord alongside field nullability.

activity class-attribute instance-attribute #

activity: UndefinedNoneOr[MessageActivity] = field(hash=False, eq=False, repr=False)

The message activity.

Note

This will only be provided for messages with rich-presence related chat embeds.

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.

application class-attribute instance-attribute #

application: UndefinedNoneOr[MessageApplication] = field(hash=False, eq=False, repr=False)

The message application.

Note

This will only be provided for messages with rich-presence related chat embeds.

application_id class-attribute instance-attribute #

application_id: UndefinedNoneOr[Snowflake] = field(hash=False, eq=False, repr=False)

ID of the application this message was sent by.

Note

This will only be provided for interaction messages.

attachments class-attribute instance-attribute #

attachments: UndefinedOr[Sequence[Attachment]] = field(hash=False, eq=False, repr=False)

The message attachments.

author class-attribute instance-attribute #

author: UndefinedOr[User] = field(hash=False, eq=False, repr=True)

The author of this message.

This will also be hikari.undefined.UNDEFINED in some cases such as when Discord updates a message with an embed URL preview or in messages fetched from the REST API.

channel_id class-attribute instance-attribute #

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

The ID of the channel that the message was sent in.

channel_mention_ids property #

channel_mention_ids: UndefinedOr[Sequence[Snowflake]]

Ids of channels that reference channels in the target crosspost's guild.

If the message is not crossposted, this will always be empty.

Warning

If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.

This is a Discord limitation.

channel_mentions class-attribute instance-attribute #

channel_mentions: UndefinedOr[Mapping[Snowflake, PartialChannel]] = field(hash=False, eq=False, repr=False)

Channel mentions that reference channels in the target crosspost's guild.

If the message is not crossposted, this will always be empty.

Warning

If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.

This is a Discord limitation.

components class-attribute instance-attribute #

components: UndefinedOr[Sequence[MessageActionRowComponent]] = field(hash=False, eq=False, repr=False)

Sequence of the components attached to this message.

content class-attribute instance-attribute #

content: UndefinedNoneOr[str] = field(hash=False, eq=False, repr=False)

The content of the message.

edited_timestamp class-attribute instance-attribute #

edited_timestamp: UndefinedNoneOr[datetime] = field(hash=False, eq=False, repr=False)

The timestamp that the message was last edited at.

Will be [None] if the message wasn't ever edited, or hikari.undefined.UNDEFINED if the info is not available.

embeds class-attribute instance-attribute #

embeds: UndefinedOr[Sequence[Embed]] = field(hash=False, eq=False, repr=False)

The message embeds.

flags class-attribute instance-attribute #

flags: UndefinedOr[MessageFlag] = field(hash=False, eq=False, repr=False)

The message flags.

guild_id class-attribute instance-attribute #

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

The ID of the guild that the message was sent in or None for messages out of guilds.

Warning

This will also be None for messages received from the REST API. This is a Discord limitation as stated here https://github.com/discord/discord-api-docs/issues/912

id class-attribute instance-attribute #

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

The ID of this entity.

interaction class-attribute instance-attribute #

interaction: UndefinedNoneOr[MessageInteraction] = field(hash=False, eq=False, repr=False)

Information about the interaction this message was created by.

is_pinned class-attribute instance-attribute #

is_pinned: UndefinedOr[bool] = field(hash=False, eq=False, repr=False)

Whether the message is pinned.

is_tts class-attribute instance-attribute #

is_tts: UndefinedOr[bool] = field(hash=False, eq=False, repr=False)

Whether the message is a TTS message.

member class-attribute instance-attribute #

member: UndefinedNoneOr[Member] = field(hash=False, eq=False, repr=False)

The member for the author who created the message.

If the message is not in a guild, this will be None.

This will also be hikari.undefined.UNDEFINED in some cases such as when Discord updates a message with an embed URL preview.

Warning

This will also be None for messages received from the REST API. This is a Discord limitation as stated here https://github.com/discord/discord-api-docs/issues/912

mentions_everyone class-attribute instance-attribute #

mentions_everyone: UndefinedOr[bool] = field(hash=False, eq=False, repr=False)

Whether the message notifies using @everyone or @here.

Warning

If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.

This is a Discord limitation.

message_reference class-attribute instance-attribute #

message_reference: UndefinedNoneOr[MessageReference] = field(hash=False, eq=False, repr=False)

The message reference data.

nonce class-attribute instance-attribute #

nonce: UndefinedNoneOr[str] = field(hash=False, eq=False, repr=False)

The message nonce.

This is a string used for validating a message was sent.

reactions class-attribute instance-attribute #

reactions: UndefinedOr[Sequence[Reaction]] = field(hash=False, eq=False, repr=False)

The message reactions.

referenced_message class-attribute instance-attribute #

referenced_message: UndefinedNoneOr[PartialMessage] = field(hash=False, eq=False, repr=False)

The message that was replied to.

If type is hikari.messages.MessageType.REPLY and hikari.undefined.UNDEFINED, Discord's backend didn't attempt to fetch the message, so the status is unknown. If type is hikari.messages.MessageType.REPLY and None, the message was deleted.

role_mention_ids class-attribute instance-attribute #

role_mention_ids: UndefinedOr[Sequence[Snowflake]] = field(hash=False, eq=False, repr=False)

IDs of roles that were notified by their mention in the message.

Warning

If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.

This is a Discord limitation.

stickers class-attribute instance-attribute #

stickers: UndefinedOr[Sequence[PartialSticker]] = field(hash=False, eq=False, repr=False)

The stickers sent with this message.

timestamp class-attribute instance-attribute #

timestamp: UndefinedOr[datetime] = field(hash=False, eq=False, repr=False)

The timestamp that the message was sent at.

type class-attribute instance-attribute #

type: UndefinedOr[Union[MessageType, int]] = field(hash=False, eq=False, repr=False)

The message type.

user_mentions class-attribute instance-attribute #

user_mentions: UndefinedOr[Mapping[Snowflake, User]] = field(hash=False, eq=False, repr=False)

Users who were notified by their mention in the message.

Warning

If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.

This is a Discord limitation.

user_mentions_ids property #

user_mentions_ids: UndefinedOr[Sequence[Snowflake]]

Ids of the users who were notified by their mention in the message.

Warning

If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.

This is a Discord limitation.

webhook_id class-attribute instance-attribute #

webhook_id: UndefinedNoneOr[Snowflake] = field(hash=False, eq=False, repr=False)

If the message was generated by a webhook, the webhook's ID.

add_reaction async #

add_reaction(emoji: Union[str, Emoji], emoji_id: UndefinedOr[SnowflakeishOr[CustomEmoji]] = undefined.UNDEFINED) -> None

Add a reaction to this message.

PARAMETER DESCRIPTION
emoji

Object or name of the emoji to react with.

Note that if the emoji is an hikari.emojis.CustomEmoji and is not from a guild the bot user is in, then this will fail.

TYPE: Union[str, Emoji]

emoji_id

ID of the custom emoji to react with. This should only be provided when a custom emoji's name is passed for emoji.

Note that this will fail if the emoji is from a guild the bot isn't in.

TYPE: UndefinedOr[SnowflakeishOr[CustomEmoji]] DEFAULT: UNDEFINED

Examples:

# Using a unicode emoji.
await message.add_reaction("👌")

# Using a unicode emoji name.
await message.add_reaction("\N{OK HAND SIGN}")

# Using the name and id.
await message.add_reaction("rooAYAYA", 705837374319493284)

# Using an Emoji-derived object.
await message.add_reaction(some_emoji_object)
RAISES DESCRIPTION
BadRequestError

If the emoji is invalid, unknown, or formatted incorrectly.

ForbiddenError

If this is the first reaction using this specific emoji on this message and you lack the hikari.permissions.Permissions.ADD_REACTIONS permission. If you lack hikari.permissions.Permissions.READ_MESSAGE_HISTORY, this may also raise this error.

NotFoundError

If the channel or message is not found, or if the emoji is not found.

This will also occur if you try to add an emoji from a guild you are not part of if no one else has previously reacted with the same emoji.

delete async #

delete() -> None

Delete this message.

RAISES DESCRIPTION
NotFoundError

If the channel this message was created in is not found, or if the message has already been deleted.

ForbiddenError

If you lack the permissions to delete the message.

edit async #

edit(content: UndefinedOr[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, 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: UndefinedOr[MessageFlag] = undefined.UNDEFINED) -> Message

Edit an existing message in a given channel.

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.

Warning

If the message was not sent by your user, the only parameter you may provide to this call is the flags parameter. Anything else will result in a hikari.errors.ForbiddenError being raised.

PARAMETER DESCRIPTION
content

If provided, the message content to update with. If hikari.undefined.UNDEFINED, then the content will not be changed. If None, then the content will be removed.

Any other value will be cast to a str before sending.

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.

TYPE: UndefinedOr[Any] DEFAULT: UNDEFINED

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]] DEFAULT: UNDEFINED

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]]] DEFAULT: UNDEFINED

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] DEFAULT: UNDEFINED

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]] DEFAULT: UNDEFINED

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] DEFAULT: UNDEFINED

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]] DEFAULT: UNDEFINED

mentions_everyone

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] DEFAULT: UNDEFINED

mentions_reply

If provided, whether to mention the author of the message that is being replied to.

This will not do anything if this is not a reply message.

TYPE: UndefinedOr[bool] DEFAULT: UNDEFINED

user_mentions

Sanitation for user mentions. If hikari.undefined.UNDEFINED, then the previous setting is not changed. If True, all valid user mentions will behave as mentions. If False, all valid user mentions will not behave as mentions.

You may alternatively pass a collection of hikari.snowflakes.Snowflake user IDs, or hikari.users.PartialUser-derived objects.

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

role_mentions

Sanitation for role mentions. If hikari.undefined.UNDEFINED, then the previous setting is not changed. If True, all valid role mentions will behave as mentions. If False, all valid role mentions will not behave as mentions.

You may alternatively pass a collection of hikari.snowflakes.Snowflake role IDs, or hikari.guilds.PartialRole-derived objects.

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

flags

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. If you have hikari.permissions.Permissions.MANAGE_MESSAGES permissions, you can use this call to suppress embeds on another user's message.

TYPE: UndefinedOr[MessageFlag] DEFAULT: UNDEFINED

RETURNS DESCRIPTION
Message

The edited message.

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

ForbiddenError

If you lack permissions to send messages in the given channel; if you try to change the contents of another user's message; or if you try to edit the flags on another user's message without the permissions to manage messages.

NotFoundError

If the channel or message is not found.

InternalServerError

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

fetch_channel async #

fetch_channel() -> PartialChannel

Fetch the channel this message was created in.

RETURNS DESCRIPTION
PartialChannel

The object of the channel this message belongs to.

RAISES DESCRIPTION
BadRequestError

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.

ForbiddenError

If you don't have access to the channel this message belongs to.

NotFoundError

If the channel this message was created in does not exist.

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.

get_member_mentions #

get_member_mentions() -> UndefinedOr[Mapping[Snowflake, Member]]

Discover any cached members notified by this message.

If this message was sent in a DM, this will always be empty.

Warning

This will only return valid results on gateway events. For REST endpoints, this will potentially be empty. This is a limitation of Discord's API, as they do not consistently notify of the ID of the guild a message was sent in.

Note

If you are using a stateless application such as a stateless bot or a REST-only client, this will always be empty. Furthermore, if you are running a stateful bot and have the GUILD_MEMBERS intent disabled, this will also be empty.

Members that are not cached will not appear in this mapping. This means that there is a very small chance that some users provided in hikari.messages.PartialMessage.user_mentions may not be present here.

get_role_mentions #

get_role_mentions() -> UndefinedOr[Mapping[Snowflake, Role]]

Attempt to look up the roles that are notified by this message.

If this message was sent in a DM, this will always be empty.

Warning

This will only return valid results on gateway events. For REST endpoints, this will potentially be empty. This is a limitation of Discord's API, as they do not consistently notify of the ID of the guild a message was sent in.

Note

If you are using a stateless application such as a stateless bot or a REST-only client, this will always be empty. Furthermore, if you are running a stateful bot and have the GUILD intent disabled, this will also be empty.

Roles that are not cached will not appear in this mapping. This means that there is a very small chance that some role IDs provided in hikari.messages.PartialMessage.role_mention_ids may not be present here. This is a limitation of Discord, again.

make_link(guild: Optional[SnowflakeishOr[PartialGuild]]) -> str

Generate a jump link to this message.

PARAMETER DESCRIPTION
guild

Object or ID of the guild this message is in or None to generate a DM message link.

This parameter is necessary since hikari.messages.PartialMessage.guild_id isn't returned by the REST API regardless of whether the message is in a DM or not.

TYPE: Optional[SnowflakeishOr[PartialGuild]]

RETURNS DESCRIPTION
str

The jump link to the message.

remove_all_reactions async #

remove_all_reactions(emoji: UndefinedOr[Union[str, Emoji]] = undefined.UNDEFINED, emoji_id: UndefinedOr[SnowflakeishOr[CustomEmoji]] = undefined.UNDEFINED) -> None

Remove all users' reactions for a specific emoji from the message.

PARAMETER DESCRIPTION
emoji

Object or name of the emoji to get the reactions for. If not specified then all reactions are removed.

TYPE: UndefinedOr[Union[str, Emoji]] DEFAULT: UNDEFINED

emoji_id

ID of the custom emoji to react with. This should only be provided when a custom emoji's name is passed for emoji.

TYPE: UndefinedOr[SnowflakeishOr[CustomEmoji]] DEFAULT: UNDEFINED

Examples:

# Using a unicode emoji and removing all 👌 reacts from the message.
# reaction.
await message.remove_all_reactions("\N{OK HAND SIGN}")

# Using the name and id.
await message.add_reaction("rooAYAYA", 705837374319493284)

# Removing all reactions entirely.
await message.remove_all_reactions()
RAISES DESCRIPTION
ForbiddenError

If you are missing the hikari.permissions.Permissions.MANAGE_MESSAGES permission, or the permission to view the channel

NotFoundError

If the channel or message is not found, or if the emoji is not found.

BadRequestError

If the emoji is invalid, unknown, or formatted incorrectly. 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.

remove_reaction async #

remove_reaction(emoji: Union[str, Emoji], emoji_id: UndefinedOr[SnowflakeishOr[CustomEmoji]] = undefined.UNDEFINED, *, user: UndefinedOr[SnowflakeishOr[PartialUser]] = undefined.UNDEFINED) -> None

Remove a reaction from this message.

PARAMETER DESCRIPTION
emoji

Object or name of the emoji to remove the reaction for.

TYPE: Union[str, Emoji]

emoji_id

ID of the custom emoji to remove the reaction for. This should only be provided when a custom emoji's name is passed for emoji.

TYPE: UndefinedOr[SnowflakeishOr[CustomEmoji]] DEFAULT: UNDEFINED

user

The user of the reaction to remove. If unspecified, then the bot's reaction is removed instead.

TYPE: UndefinedOr[SnowflakeishOr[PartialUser]] DEFAULT: UNDEFINED

Examples:

# Using a unicode emoji and removing the bot's reaction from this
# reaction.
await message.remove_reaction("\N{OK HAND SIGN}")

# Using a custom emoji's name and ID to remove a specific user's
# reaction from this reaction.
await message.remove_reaction(
    "a:Distraction", 745991233939439616, user=some_user
)

# Using a unicode emoji and removing a specific user from this
# reaction.
await message.remove_reaction("\N{OK HAND SIGN}", user=some_user)

# Using the name and id.
await message.add_reaction("rooAYAYA", 705837374319493284)

# Using an Emoji object and removing a specific user from this
# reaction.
await message.remove_reaction(some_emoji_object, user=some_user)
RAISES DESCRIPTION
BadRequestError

If the emoji is invalid, unknown, or formatted incorrectly. 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.

ForbiddenError

If this is the first reaction using this specific emoji on this message and you lack the hikari.permissions.Permissions.ADD_REACTIONS permission. If you lack hikari.permissions.Permissions.READ_MESSAGE_HISTORY, this may also raise this error. If you remove the reaction of another user without hikari.permissions.Permissions.MANAGE_MESSAGES, this will be raised.

NotFoundError

If the channel or message is not found, or if the emoji is not found.

respond async #

respond(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, sticker: UndefinedOr[SnowflakeishOr[PartialSticker]] = undefined.UNDEFINED, stickers: UndefinedOr[SnowflakeishSequence[PartialSticker]] = undefined.UNDEFINED, tts: UndefinedOr[bool] = undefined.UNDEFINED, reply: Union[UndefinedType, SnowflakeishOr[PartialMessage], bool] = 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

Create a message in the channel this message belongs to.

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

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] DEFAULT: UNDEFINED

attachments

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

TYPE: UndefinedOr[Sequence[Resourceish]] DEFAULT: UNDEFINED

component

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

TYPE: UndefinedOr[ComponentBuilder] DEFAULT: UNDEFINED

components

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

TYPE: UndefinedOr[Sequence[ComponentBuilder]] DEFAULT: UNDEFINED

embed

If provided, the message embed.

TYPE: UndefinedOr[Embed] DEFAULT: UNDEFINED

embeds

If provided, the message embeds.

TYPE: UndefinedOr[Sequence[Embed]] DEFAULT: UNDEFINED

sticker

If provided, object or ID of a sticker to send on the message.

As of writing, bots can only send custom stickers from the current guild.

TYPE: UndefinedOr[SnowflakeishOr[PartialSticker]] DEFAULT: UNDEFINED

stickers

If provided, object or ID of up to 3 stickers to send on the message.

As of writing, bots can only send custom stickers from the current guild.

TYPE: UndefinedOr[SnowflakeishSequence[PartialSticker]] DEFAULT: UNDEFINED

tts

If provided, whether the message will be TTS (Text To Speech).

TYPE: UndefinedOr[bool] DEFAULT: UNDEFINED

reply

If provided and True, reply to this message. If provided and not bool, the message to reply to.

TYPE: Union[UndefinedType, SnowflakeishOr[PartialMessage], bool] DEFAULT: UNDEFINED

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] DEFAULT: UNDEFINED

mentions_everyone

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

TYPE: UndefinedOr[bool] DEFAULT: UNDEFINED

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] DEFAULT: UNDEFINED

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]] DEFAULT: UNDEFINED

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]] DEFAULT: UNDEFINED

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: Union[UndefinedType, int, MessageFlag] DEFAULT: UNDEFINED

RETURNS DESCRIPTION
Message

The created message.

RAISES DESCRIPTION
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 lack permissions to send messages in the given channel.

NotFoundError

If the channel is not found.

InternalServerError

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

ValueError

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

TypeError

If both attachment and attachments are specified.

Reaction #

Represents a reaction in a message.

count class-attribute instance-attribute #

count: int = field(eq=False, hash=False, repr=True)

The number of times the emoji has been used to react.

emoji class-attribute instance-attribute #

emoji: Union[UnicodeEmoji, CustomEmoji] = field(hash=True, repr=True)

The emoji used to react.

is_me class-attribute instance-attribute #

is_me: bool = field(eq=False, hash=False, repr=False)

Whether the current user reacted using this emoji.