Skip to main content
Message is the full representation of a message. Created when MESSAGE_CREATE and MESSAGE_UPDATE events are received. PartialMessage is a reduced version, available in MESSAGE_DELETE.

Message - Fields


PartialMessage - Fields

Available in DispatchEvent::MessageDelete.

Constructors

Message::from_api

Creates a Message from a deserialized API response.

Message::from_value

Deserializes a Message from a serde_json::Value. Additionally stores the member field in member_data if present in the payload. Returns None on deserialization failure.

Methods

Sending

send

Sends a new message to the same channel as the current message.

send_files

Sends a message with files to the same channel via multipart/form-data. See Files for details on FileAttachment.

send_to

Sends a message to an arbitrary channel by ID.

Replies

reply

Replies to the message with the given text. message_reference is set automatically.

reply_with

Replies with an arbitrary MessagePayloadData. The message_reference field is set automatically - no need to fill it manually.

reply_with_files

Replies with files. message_reference is set automatically.

Edit and delete

edit

Edits the current message. Bots can only edit their own messages.

edit_files

Edits the current message with files. Bots can only edit their own messages.

delete

Deletes the message.

fetch

Fetches the current message data from the API using channel_id and id.

Reactions

add_reaction

Adds a reaction from the bot. For Unicode: pass the character ("πŸ‘"). For custom emoji: "name:id".

remove_reaction

Removes the bot’s own reaction.

remove_user_reaction

Removes a specific user’s reaction. Requires MANAGE_MESSAGES.

remove_all_reactions

Removes all reactions with all emoji. Requires MANAGE_MESSAGES.

remove_reaction_emoji

Removes all reactions for a specific emoji.

fetch_reaction_users

Returns the list of users who reacted with the specified emoji.

Pinning

pin / unpin

Pins or unpins the message in the channel. Requires MANAGE_MESSAGES.

Attachments

delete_attachment

Deletes a specific attachment from the message.

Helpers

mention_author

Returns the author mention string in the format <@user_id>.

MessageType

Message type, available in the message_type field.
A Reply type does not guarantee that referenced_message is populated. The original message may have been deleted.