Struct serenity::builder::CreateMessage [−][src]
pub struct CreateMessage<'a>(pub HashMap<&'static str, Value>, pub Option<Vec<ReactionType>>, pub Vec<AttachmentType<'a>>);
Expand description
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:
- When sending an
Self::embed
, no other field is required; - Otherwise,
Self::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
});
Tuple Fields
0: HashMap<&'static str, Value>
1: Option<Vec<ReactionType>>
2: Vec<AttachmentType<'a>>
Implementations
Set the content of the message.
Note: Message contents must be under 2000 unicode code points.
pub fn add_embed<F>(&mut self, f: F) -> &mut Self where
F: FnOnce(&mut CreateEmbed) -> &mut CreateEmbed,
pub fn add_embed<F>(&mut self, f: F) -> &mut Self where
F: FnOnce(&mut CreateEmbed) -> &mut CreateEmbed,
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.
pub fn embed<F>(&mut self, f: F) -> &mut Self where
F: FnOnce(&mut CreateEmbed) -> &mut CreateEmbed,
pub fn embed<F>(&mut self, f: F) -> &mut Self where
F: FnOnce(&mut CreateEmbed) -> &mut CreateEmbed,
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
.
pub fn reactions<R: Into<ReactionType>, It: IntoIterator<Item = R>>(
&mut self,
reactions: It
) -> &mut Self
pub fn reactions<R: Into<ReactionType>, It: IntoIterator<Item = R>>(
&mut self,
reactions: It
) -> &mut Self
Adds a list of reactions to create after the message’s sent.
Appends a file to the message.
pub fn add_files<T: Into<AttachmentType<'a>>, It: IntoIterator<Item = T>>(
&mut self,
files: It
) -> &mut Self
pub fn add_files<T: Into<AttachmentType<'a>>, It: IntoIterator<Item = T>>(
&mut self,
files: It
) -> &mut Self
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
pub fn files<T: Into<AttachmentType<'a>>, It: IntoIterator<Item = T>>(
&mut self,
files: It
) -> &mut Self
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.
pub fn allowed_mentions<F>(&mut self, f: F) -> &mut Self where
F: FnOnce(&mut CreateAllowedMentions) -> &mut CreateAllowedMentions,
pub fn allowed_mentions<F>(&mut self, f: F) -> &mut Self where
F: FnOnce(&mut CreateAllowedMentions) -> &mut CreateAllowedMentions,
Set the allowed mentions for the message.
Set the reference message this message is a reply to.
pub fn components<F>(&mut self, f: F) -> &mut Self where
F: FnOnce(&mut CreateComponents) -> &mut CreateComponents,
pub fn components<F>(&mut self, f: F) -> &mut Self where
F: FnOnce(&mut CreateComponents) -> &mut CreateComponents,
Creates components for this message.
Sets the components of this message.
Sets the flags for the message.
Trait Implementations
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
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
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