hikari.messages#

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

Module Contents#

class hikari.messages.MessageType[source]#

Bases: int, hikari.internal.enums.Enum

The type of a message.

DEFAULT = 0[source]#

A normal message.

RECIPIENT_ADD = 1[source]#

A message to denote a new recipient in a group.

RECIPIENT_REMOVE = 2[source]#

A message to denote that a recipient left the group.

CALL = 3[source]#

A message to denote a VoIP call.

CHANNEL_NAME_CHANGE = 4[source]#

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

CHANNEL_ICON_CHANGE = 5[source]#

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

CHANNEL_PINNED_MESSAGE = 6[source]#

A message to denote that a message was pinned.

GUILD_MEMBER_JOIN = 7[source]#

A message to denote that a member joined the guild.

USER_PREMIUM_GUILD_SUBSCRIPTION = 8[source]#

A message to denote a Nitro subscription.

USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1 = 9[source]#

A message to denote a tier 1 Nitro subscription.

USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 = 10[source]#

A message to denote a tier 2 Nitro subscription.

USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = 11[source]#

A message to denote a tier 3 Nitro subscription.

CHANNEL_FOLLOW_ADD = 12[source]#

Channel follow add.

GUILD_DISCOVERY_DISQUALIFIED = 14[source]#

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

GUILD_DISCOVERY_REQUALIFIED = 15[source]#

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

GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING = 16[source]#

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

GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING = 17[source]#

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

REPLY = 19[source]#

A message that replies to another message.

CHAT_INPUT = 20[source]#

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

GUILD_INVITE_REMINDER = 22[source]#

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

CONTEXT_MENU_COMMAND = 23[source]#

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

class hikari.messages.MessageFlag[source]#

Bases: hikari.internal.enums.Flag

Additional flags for message options.

NONE = 0[source]#

None.

CROSSPOSTED[source]#

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

IS_CROSSPOST[source]#

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

SUPPRESS_EMBEDS[source]#

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

SOURCE_MESSAGE_DELETED[source]#

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

URGENT[source]#

This message came from the urgent message system.

EPHEMERAL[source]#

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

LOADING[source]#

This message symbolizes that the interaction is ‘thinking’.

FAILED_TO_MENTION_SOME_ROLES_IN_THREAD[source]#

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

class hikari.messages.MessageActivityType[source]#

Bases: int, hikari.internal.enums.Enum

The type of a rich presence message activity.

NONE = 0[source]#

No activity.

JOIN = 1[source]#

Join an activity.

SPECTATE = 2[source]#

Spectating something.

LISTEN = 3[source]#

Listening to something.

JOIN_REQUEST = 5[source]#

Request to join an activity.

class hikari.messages.Attachment[source]#

Bases: hikari.snowflakes.Unique, hikari.files.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.

id: hikari.snowflakes.Snowflake[source]#

The ID of this entity.

url: str[source]#

The source URL of file.

filename: str[source]#

The name of the file.

media_type: Optional[str][source]#

The media type of the file.

size: int[source]#

The size of the file in bytes.

proxy_url: str[source]#

The proxied URL of file.

height: Optional[int][source]#

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

width: Optional[int][source]#

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

is_ephemeral: bool[source]#

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

class hikari.messages.Reaction[source]#

Represents a reaction in a message.

count: int[source]#

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

emoji: Union[hikari.emojis.UnicodeEmoji, hikari.emojis.CustomEmoji][source]#

The emoji used to react.

is_me: bool[source]#

Whether the current user reacted using this emoji.

class hikari.messages.MessageActivity[source]#

Represents the activity of a rich presence-enabled message.

type: Union[MessageActivityType, int][source]#

The type of message activity.

party_id: Optional[str][source]#

The party ID of the message activity.

class hikari.messages.MessageReference[source]#

Represents information about a referenced message.

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

app: hikari.traits.RESTAware[source]#

Client application that models may use for procedures.

id: Optional[hikari.snowflakes.Snowflake][source]#

The ID of the original message.

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

channel_id: hikari.snowflakes.Snowflake[source]#

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

guild_id: Optional[hikari.snowflakes.Snowflake][source]#

The ID of the guild that the message originated from.

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

class hikari.messages.MessageInteraction[source]#

Representation of information provided for a message from an interaction.

id: hikari.snowflakes.Snowflake[source]#

ID of the interaction this message was sent by.

type: Union[hikari.interactions.base_interactions.InteractionType, int][source]#

The type of interaction this message was created by.

name: str[source]#

Name of the application command the interaction is tied to.

user: hikari.users.User[source]#

Object of the user who invoked this interaction.

class hikari.messages.PartialMessage[source]#

Bases: hikari.snowflakes.Unique

A message representation containing partially populated information.

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

Warning

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

property channel_mention_ids: hikari.undefined.UndefinedOr[Sequence[hikari.snowflakes.Snowflake]][source]#

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.

property user_mentions_ids: hikari.undefined.UndefinedOr[Sequence[hikari.snowflakes.Snowflake]][source]#

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.

app: hikari.traits.RESTAware[source]#

Client application that models may use for procedures.

id: hikari.snowflakes.Snowflake[source]#

The ID of this entity.

channel_id: hikari.snowflakes.Snowflake[source]#

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

guild_id: Optional[hikari.snowflakes.Snowflake][source]#

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>

author: hikari.undefined.UndefinedOr[hikari.users.User][source]#

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.

member: hikari.undefined.UndefinedNoneOr[hikari.guilds.Member][source]#

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>

content: hikari.undefined.UndefinedNoneOr[str][source]#

The content of the message.

timestamp: hikari.undefined.UndefinedOr[datetime.datetime][source]#

The timestamp that the message was sent at.

edited_timestamp: hikari.undefined.UndefinedNoneOr[datetime.datetime][source]#

The timestamp that the message was last edited at.

Will be None if the message wasn’t ever edited, or undefined if the info is not available.

is_tts: hikari.undefined.UndefinedOr[bool][source]#

Whether the message is a TTS message.

user_mentions: hikari.undefined.UndefinedOr[Mapping[hikari.snowflakes.Snowflake, hikari.users.User]][source]#

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.

role_mention_ids: hikari.undefined.UndefinedOr[Sequence[hikari.snowflakes.Snowflake]][source]#

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.

channel_mentions: hikari.undefined.UndefinedOr[Mapping[hikari.snowflakes.Snowflake, hikari.channels.PartialChannel]][source]#

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.

mentions_everyone: hikari.undefined.UndefinedOr[bool][source]#

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.

attachments: hikari.undefined.UndefinedOr[Sequence[Attachment]][source]#

The message attachments.

embeds: hikari.undefined.UndefinedOr[Sequence[hikari.embeds.Embed]][source]#

The message embeds.

reactions: hikari.undefined.UndefinedOr[Sequence[Reaction]][source]#

The message reactions.

is_pinned: hikari.undefined.UndefinedOr[bool][source]#

Whether the message is pinned.

webhook_id: hikari.undefined.UndefinedNoneOr[hikari.snowflakes.Snowflake][source]#

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

type: hikari.undefined.UndefinedOr[Union[MessageType, int]][source]#

The message type.

activity: hikari.undefined.UndefinedNoneOr[MessageActivity][source]#

The message activity.

Note

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

application: hikari.undefined.UndefinedNoneOr[MessageApplication][source]#

The message application.

Note

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

message_reference: hikari.undefined.UndefinedNoneOr[MessageReference][source]#

The message reference data.

flags: hikari.undefined.UndefinedOr[MessageFlag][source]#

The message flags.

stickers: hikari.undefined.UndefinedOr[Sequence[hikari.stickers.PartialSticker]][source]#

The stickers sent with this message.

nonce: hikari.undefined.UndefinedNoneOr[str][source]#

The message nonce.

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

referenced_message: hikari.undefined.UndefinedNoneOr[PartialMessage][source]#

The message that was replied to.

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

interaction: hikari.undefined.UndefinedNoneOr[MessageInteraction][source]#

Information about the interaction this message was created by.

application_id: hikari.undefined.UndefinedNoneOr[hikari.snowflakes.Snowflake][source]#

ID of the application this message was sent by.

Note

This will only be provided for interaction messages.

components: hikari.undefined.UndefinedOr[Sequence[hikari.components.MessageActionRowComponent]][source]#

Sequence of the components attached to this message.

get_member_mentions()[source]#

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 notified_users may not be present here.

get_role_mentions()[source]#

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 notifies_role_ids may not be present here. This is a limitation of Discord, again.

Generate a jump link to this message.

Other Parameters
guildtyping.Optional[hikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]]

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

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

Returns
str

The jump link to the message.

async fetch_channel()[source]#

Fetch the channel this message was created in.

Returns
hikari.channels.PartialChannel

The object of the channel this message belongs to.

Raises
hikari.errors.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.

hikari.errors.ForbiddenError

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

hikari.errors.NotFoundError

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

hikari.errors.UnauthorizedError

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

hikari.errors.RateLimitTooLongError

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

hikari.errors.RateLimitedError

Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.

hikari.errors.InternalServerError

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

async edit(content=undefined.UNDEFINED, *, attachment=undefined.UNDEFINED, attachments=undefined.UNDEFINED, component=undefined.UNDEFINED, components=undefined.UNDEFINED, embed=undefined.UNDEFINED, embeds=undefined.UNDEFINED, mentions_everyone=undefined.UNDEFINED, mentions_reply=undefined.UNDEFINED, user_mentions=undefined.UNDEFINED, role_mentions=undefined.UNDEFINED, flags=undefined.UNDEFINED)[source]#

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.

Parameters
contenthikari.undefined.UndefinedOr[typing.Any]

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.

Other Parameters
attachmenthikari.undefined.UndefinedNoneOr[typing.Union[hikari.files.Resourceish, hikari.messages.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.

attachmentshikari.undefined.UndefinedNoneOr[typing.Sequence[typing.Union[hikari.files.Resourceish, hikari.messages.Attachment]]]

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.

componenthikari.undefined.UndefinedNoneOr[hikari.api.special_endpoints.ComponentBuilder]

If provided, builder object of the component to set for this message. This component will replace any previously set components and passing None will remove all components.

componentshikari.undefined.UndefinedNoneOr[typing.Sequence[hikari.api.special_endpoints.ComponentBuilder]]

If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing None or an empty sequence will remove all components.

embedhikari.undefined.UndefinedNoneOr[hikari.embeds.Embed]

If provided, the embed to set on the message. If hikari.undefined.UNDEFINED, the previous embed(s) are not changed. If this is None then any present embeds are removed. Otherwise, the new embed that was provided will be used as the replacement.

embedshikari.undefined.UndefinedNoneOr[typing.Sequence[hikari.embeds.Embed]]

If provided, the embeds to set on the message. If hikari.undefined.UNDEFINED, the previous embed(s) are not changed. If this is None then any present embeds are removed. Otherwise, the new embeds that were provided will be used as the replacement.

mentions_everyonehikari.undefined.UndefinedOr[bool]

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.

mentions_replyhikari.undefined.UndefinedOr[bool]

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.

user_mentionshikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]]

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.

role_mentionshikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], bool]]

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.

flagshikari.undefined.UndefinedOr[hikari.messages.MessageFlag]

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 NONE and SUPPRESS_EMBEDS. If you have MANAGE_MESSAGES permissions, you can use this call to suppress embeds on another user’s message.

Returns
hikari.messages.Message

The edited message.

Raises
hikari.errors.BadRequestError

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

hikari.errors.UnauthorizedError

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

hikari.errors.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.

hikari.errors.NotFoundError

If the channel or message is not found.

hikari.errors.InternalServerError

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

async respond(content=undefined.UNDEFINED, *, attachment=undefined.UNDEFINED, attachments=undefined.UNDEFINED, component=undefined.UNDEFINED, components=undefined.UNDEFINED, embed=undefined.UNDEFINED, embeds=undefined.UNDEFINED, tts=undefined.UNDEFINED, reply=undefined.UNDEFINED, mentions_everyone=undefined.UNDEFINED, mentions_reply=undefined.UNDEFINED, user_mentions=undefined.UNDEFINED, role_mentions=undefined.UNDEFINED, flags=undefined.UNDEFINED)[source]#

Create a message in the channel this message belongs to.

Parameters
contenthikari.undefined.UndefinedOr[typing.Any]

If provided, the message contents. If hikari.undefined.UNDEFINED, then nothing will be sent in the content. Any other value here will be cast to a str.

If this is a hikari.embeds.Embed and no embed nor embeds kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.

Likewise, if this is a hikari.files.Resource, then the content is instead treated as an attachment if no attachment and no attachments kwargs are provided.

Other Parameters
attachmenthikari.undefined.UndefinedOr[hikari.files.Resourceish],

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

Attachments can be passed as many different things, to aid in convenience.

  • If a pathlib.PurePath or str to a valid URL, the

    resource at the given URL will be streamed to Discord when sending the message. Subclasses of hikari.files.WebResource such as hikari.files.URL, hikari.messages.Attachment, hikari.emojis.Emoji, EmbedResource, etc will also be uploaded this way. This will use bit-inception, so only a small percentage of the resource will remain in memory at any one time, thus aiding in scalability.

  • If a hikari.files.Bytes is passed, or a str

    that contains a valid data URI is passed, then this is uploaded with a randomized file name if not provided.

  • If a hikari.files.File, pathlib.PurePath or

    str that is an absolute or relative path to a file on your file system is passed, then this resource is uploaded as an attachment using non-blocking code internally and streamed using bit-inception where possible. This depends on the type of concurrent.futures.Executor that is being used for the application (default is a thread pool which supports this behaviour).

attachmentshikari.undefined.UndefinedOr[typing.Sequence[hikari.files.Resourceish]],

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

componenthikari.undefined.UndefinedOr[hikari.api.special_endpoints.ComponentBuilder]

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

componentshikari.undefined.UndefinedOr[typing.Sequence[hikari.api.special_endpoints.ComponentBuilder]]

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

embedhikari.undefined.UndefinedOr[hikari.embeds.Embed]

If provided, the message embed.

embedshikari.undefined.UndefinedOr[typing.Sequence[hikari.embeds.Embed]]

If provided, the message embeds.

ttshikari.undefined.UndefinedOr[bool]

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

replytyping.Union[hikari.undefined.UndefinedType, hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage], bool]

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

mentions_everyonehikari.undefined.UndefinedOr[bool]

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

mentions_replyhikari.undefined.UndefinedOr[bool]

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

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

user_mentionshikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]]

If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed. Alternatively this may be a collection of hikari.snowflakes.Snowflake, or hikari.users.PartialUser derivatives to enforce mentioning specific users.

role_mentionshikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], bool]]

If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed. Alternatively this may be a collection of hikari.snowflakes.Snowflake, or hikari.guilds.PartialRole derivatives to enforce mentioning specific roles.

flagshikari.undefined.UndefinedOr[hikari.messages.MessageFlag]

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 NONE and SUPPRESS_EMBEDS.

Returns
hikari.messages.Message

The created message.

Raises
hikari.errors.BadRequestError

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

hikari.errors.UnauthorizedError

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

hikari.errors.ForbiddenError

If you lack permissions to send messages in the given channel.

hikari.errors.NotFoundError

If the channel is not found.

hikari.errors.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.

async delete()[source]#

Delete this message.

Raises
hikari.errors.NotFoundError

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

hikari.errors.ForbiddenError

If you lack the permissions to delete the message.

async add_reaction(emoji)[source]#
async add_reaction(emoji: str, emoji_id: hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji]) None

Add a reaction to this message.

Parameters
emojityping.Union[str, hikari.emojis.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.

Other Parameters
emoji_idhikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji]]

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.

Raises
hikari.errors.BadRequestError

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

hikari.errors.ForbiddenError

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

hikari.errors.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.

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)
async remove_reaction(emoji, *, user=undefined.UNDEFINED)[source]#
async remove_reaction(emoji: str, emoji_id: hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji], *, user: hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]] = undefined.UNDEFINED) None

Remove a reaction from this message.

Parameters
emojityping.Union[str, hikari.emojis.Emoji]

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

Other Parameters
emoji_idhikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji]]

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.

userhikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]]

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

Raises
hikari.errors.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.

hikari.errors.ForbiddenError

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

hikari.errors.NotFoundError

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

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)
async remove_all_reactions()[source]#
async remove_all_reactions(emoji: Union[str, hikari.emojis.Emoji]) None
async remove_all_reactions(emoji: str, emoji_id: hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji]) None

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

Other Parameters
emojihikari.undefined.UndefinedOr[typing.Union[str, hikari.emojis.Emoji]]

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

emoji_idhikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji]]

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

Raises
hikari.errors.ForbiddenError

If you are missing the MANAGE_MESSAGES permission, or the permission to view the channel

hikari.errors.NotFoundError

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

hikari.errors.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.

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()
class hikari.messages.Message[source]#

Bases: PartialMessage

Represents a message with all known details.

author: hikari.users.User[source]#

The author of this message.

member: Optional[hikari.guilds.Member][source]#

The member properties for the message’s author.

content: Optional[str][source]#

The content of the message.

timestamp: datetime.datetime[source]#

The timestamp that the message was sent at.

edited_timestamp: Optional[datetime.datetime][source]#

The timestamp that the message was last edited at.

Will be None if it wasn’t ever edited.

is_tts: bool[source]#

Whether the message is a TTS message.

attachments: Sequence[Attachment][source]#

The message attachments.

embeds: Sequence[hikari.embeds.Embed][source]#

The message embeds.

reactions: Sequence[Reaction][source]#

The message reactions.

is_pinned: bool[source]#

Whether the message is pinned.

webhook_id: Optional[hikari.snowflakes.Snowflake][source]#

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

type: Union[MessageType, int][source]#

The message type.

activity: Optional[MessageActivity][source]#

The message activity.

Note

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

application: Optional[MessageApplication][source]#

The message application.

Note

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

message_reference: Optional[MessageReference][source]#

The message reference data.

flags: MessageFlag[source]#

The message flags.

stickers: Sequence[hikari.stickers.PartialSticker][source]#

The stickers sent with this message.

nonce: Optional[str][source]#

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

referenced_message: Optional[PartialMessage][source]#

The message that was replied to.

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

interaction: Optional[MessageInteraction][source]#

Information about the interaction this message was created by.

application_id: Optional[hikari.snowflakes.Snowflake][source]#

ID of the application this message was sent by.

Note

This will only be provided for interaction messages.

components: Sequence[hikari.components.MessageActionRowComponent][source]#

Sequence of the components attached to this message.