MessagePayload is a builder pattern for constructing MessagePayloadData. Used in all message sending methods: channel.send, message.reply, message.edit, etc.
MessagePayloadData
The final structure passed to REST methods. All fields are optional during serialization - missing fields are not included in JSON.MessagePayloadData implements Serialize and Deserialize, so it can be stored, cloned, and passed around like a regular data structure.MessagePayload
Builder forMessagePayloadData. All methods take self and return Self - method chaining is supported.
Creating
MessagePayload::new
MessagePayload::from_content
content already set. Equivalent to MessagePayload::new().content(content).
Methods
content
embeds
add_embed
add_embed_builder
.build() on the given EmbedBuilder and appends the result. Convenient for inline chaining without an intermediate variable.
Example: message with text and an embed
Example: message with text and an embed
attachments
send_files.
reply
message_reference to reply to a specific message.
When using
message.reply() and message.reply_with(), the message_reference field is set automatically - calling reply() manually is not needed.Example: manually set a reply reference
Example: manually set a reply reference
tts
true, the message is read aloud via TTS for all channel members who have TTS enabled.
flags
attach_file
build_with_files or build_form.
attach_files
Finalizing
build
MessagePayloadData. Files added via attach_file are not included in the result - use build_with_files or build_form to send with files.
build_with_files
MessagePayloadData and the file list separately. Use together with rest.post_multipart.
build_form
multipart::Form for direct passing to rest.post_multipart. Includes payload_json and all attached files.
has_files
true if at least one file has been attached to the builder.
AttachmentPayload
Attachment metadata. Generated automatically insidebuild_multipart_form.
Examples
Message with text only
Message with text only
Multiple embed blocks
Multiple embed blocks
Send with a file
Send with a file
