pub struct CreateMessage<'a>(pub HashMap<&'static str, Value>, pub Option<Vec<ReactionType>>, pub Vec<AttachmentType<'a>>);
Available on crate feature builder only.
Expand description

A builder to specify the contents of an Http::send_message request, primarily meant for use through ChannelId::send_message.

There are three situations where different field requirements are present:

  1. When sending a message without embeds or stickers, Self::content is the only required field that is required to be set.
  2. When sending an Self::embed, no other field is required.
  3. When sending stickers with Self::sticker_id or other sticker methods, no other field is required.

Note that if you only need to send the content of a message, without specifying other fields, then ChannelId::say may be a more preferable option.

Examples

Sending a message with a content of "test" and applying text-to-speech:

use serenity::model::id::ChannelId;

let channel_id = ChannelId(7);

let _ = channel_id.send_message(&http, |m| {
    m.content("test")
        .tts(true)
        .embed(|e| e.title("This is an embed").description("With a description"))
});

Tuple Fields

0: HashMap<&'static str, Value>1: Option<Vec<ReactionType>>2: Vec<AttachmentType<'a>>
Available on crate feature model only.

Implementations

Set the content of the message.

Note: Message contents must be under 2000 unicode code points.

Add an embed for the message.

Note: This will keep all existing embeds. Use Self::set_embed() to replace existing embeds.

Add multiple embeds for the message.

Note: This will keep all existing embeds. Use Self::set_embeds() to replace existing embeds.

Set an embed for the message.

Equivalent to Self::set_embed().

Note: This will replace all existing embeds. Use Self::add_embed() to add an additional embed.

Set an embed for the message.

Equivalent to Self::embed().

Note: This will replace all existing embeds. Use Self::add_embed() to add an additional embed.

Set multiple embeds for the message.

Note: This will replace all existing embeds. Use Self::add_embeds() to keep existing embeds.

Set whether the message is text-to-speech.

Think carefully before setting this to true.

Defaults to false.

Adds a list of reactions to create after the message’s sent.

Available on crate feature model only.

Appends a file to the message.

Available on crate feature model only.

Appends a list of files to the message.

Available on crate feature model only.

Sets a list of files to include in the message.

Calling this multiple times will overwrite the file list. To append files, call Self::add_file or Self::add_files instead.

Set the allowed mentions for the message.

Set the reference message this message is a reply to.

Creates components for this message.

Sets the components of this message.

Sets the flags for the message.

Sets a single sticker ID to include in the message.

Note: This will replace all existing stickers. Use Self::add_sticker_id() to add an additional sticker.

Add a sticker ID for the message.

Note: There can be a maximum of 3 stickers in a message.

Note: This will keep all existing stickers. Use Self::set_sticker_ids() to replace existing stickers.

Add multiple sticker IDs for the message.

Note: There can be a maximum of 3 stickers in a message.

Note: This will keep all existing stickers. Use Self::set_sticker_ids() to replace existing stickers.

Sets a list of sticker IDs to include in the message.

Note: There can be a maximum of 3 stickers in a message.

Note: This will replace all existing stickers. Use Self::add_sticker_id() or Self::add_sticker_ids() to keep existing stickers.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Creates a map for sending a Message, setting Self::tts to false by default.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more