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 inDispatchEvent::MessageDelete.
Constructors
Message::from_api
Message from a deserialized API response.
Message::from_value
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
Example
Example
send_files
FileAttachment.
send_to
Replies
reply
message_reference is set automatically.
Example
Example
reply_with
MessagePayloadData. The message_reference field is set automatically - no need to fill it manually.
reply_with_files
message_reference is set automatically.
Example: reply with an embed
Example: reply with an embed
Edit and delete
edit
Example: send and edit after a delay
Example: send and edit after a delay
edit_files
Example: update message with a new file
Example: update message with a new file
delete
fetch
channel_id and id.
Reactions
add_reaction
"π"). For custom emoji: "name:id".
remove_reaction
remove_user_reaction
MANAGE_MESSAGES.
remove_all_reactions
MANAGE_MESSAGES.
remove_reaction_emoji
fetch_reaction_users
Example: add a reaction and remove it after a delay
Example: add a reaction and remove it after a delay
Example: fetch users who reacted
Example: fetch users who reacted
Pinning
pin / unpin
MANAGE_MESSAGES.
Attachments
delete_attachment
Helpers
mention_author
<@user_id>.
MessageType
Message type, available in themessage_type field.
A
Reply type does not guarantee that referenced_message is populated. The original message may have been deleted.