[][src]Struct serenity::builder::CreateMessage

pub struct CreateMessage<'a>(pub HashMap<&'static str, Value>, pub Option<Vec<ReactionType>>, pub Vec<AttachmentType<'a>>);

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

There are two situations where different field requirements are present:

  1. When sending an embed, no other field is required;
  2. Otherwise, content is the only required field that is required to be set.

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");
    m.tts(true);

    m.embed(|mut e| {
        e.title("This is an embed");
        e.description("With a description");

        e
    });

    m
});

Implementations

impl<'a> CreateMessage<'a>[src]

pub fn content<D: ToString>(&mut self, content: D) -> &mut Self[src]

Set the content of the message.

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

pub fn embed<F>(&mut self, f: F) -> &mut Self where
    F: FnOnce(&mut CreateEmbed) -> &mut CreateEmbed
[src]

Set an embed for the message.

pub fn tts(&mut self, tts: bool) -> &mut Self[src]

Set whether the message is text-to-speech.

Think carefully before setting this to true.

Defaults to false.

pub fn reactions<R: Into<ReactionType>, It: IntoIterator<Item = R>>(
    &mut self,
    reactions: It
) -> &mut Self
[src]

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

pub fn add_file<T: Into<AttachmentType<'a>>>(&mut self, file: T) -> &mut Self[src]

Appends a file to the message.

pub fn add_files<T: Into<AttachmentType<'a>>, It: IntoIterator<Item = T>>(
    &mut self,
    files: It
) -> &mut Self
[src]

Appends a list of files to the message.

pub fn files<T: Into<AttachmentType<'a>>, It: IntoIterator<Item = T>>(
    &mut self,
    files: It
) -> &mut Self
[src]

Sets a list of files to include in the message.

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

Trait Implementations

impl<'a> Clone for CreateMessage<'a>[src]

impl<'a> Debug for CreateMessage<'a>[src]

impl<'a> Default for CreateMessage<'a>[src]

pub fn default() -> CreateMessage<'a>[src]

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

Auto Trait Implementations

impl<'a> RefUnwindSafe for CreateMessage<'a>

impl<'a> Send for CreateMessage<'a>

impl<'a> Sync for CreateMessage<'a>

impl<'a> Unpin for CreateMessage<'a>

impl<'a> UnwindSafe for CreateMessage<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CloneAny for T where
    T: Clone + Any
[src]

impl<T> DebugAny for T where
    T: Any + Debug
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> UnsafeAny for T where
    T: Any

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,