Skip to main content
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 for MessagePayloadData. All methods take self and return Self - method chaining is supported.

Creating

MessagePayload::new

Creates an empty builder.

MessagePayload::from_content

Creates a builder with content already set. Equivalent to MessagePayload::new().content(content).

Methods

content

Sets the text content of the message.
Panics at runtime if the string length exceeds 2000 characters. Truncate text in advance using fluxer_util::truncate if the data source is not controlled.

embeds

Sets the embed list entirely. Replaces any previously added embeds.
Panics if embeds.len() > 10.

add_embed

Appends a single embed to the list.

add_embed_builder

Calls .build() on the given EmbedBuilder and appends the result. Convenient for inline chaining without an intermediate variable.

attachments

Sets the attachment metadata list manually. Not needed in most cases - metadata is generated automatically when calling send_files.

reply

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

tts

If true, the message is read aloud via TTS for all channel members who have TTS enabled.

flags

Sets the message bitfield flags.

attach_file

Adds a single file to the send. Files are stored inside the builder and included when calling build_with_files or build_form.

attach_files

Adds multiple files.

Finalizing

build

Extracts 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

Returns MessagePayloadData and the file list separately. Use together with rest.post_multipart.

build_form

Assembles a ready-to-use multipart::Form for direct passing to rest.post_multipart. Includes payload_json and all attached files.

has_files

Returns true if at least one file has been attached to the builder.

AttachmentPayload

Attachment metadata. Generated automatically inside build_multipart_form.

Examples