[−][src]Struct serenity::builder::CreateEmbed
A builder to create a fake Embed
object, for use with the
ChannelId::send_message
and ExecuteWebhook::embeds
methods.
Examples
Refer to the documentation for ChannelId::send_message
for a very in-depth
example on how to use this.
Methods
impl CreateEmbed
[src]
pub fn author<F>(&mut self, f: F) -> &mut Self where
F: FnOnce(&mut CreateEmbedAuthor) -> &mut CreateEmbedAuthor,
[src]
F: FnOnce(&mut CreateEmbedAuthor) -> &mut CreateEmbedAuthor,
Set the author of the embed.
Refer to the documentation for CreateEmbedAuthor
for more
information.
pub fn color<C: Into<Colour>>(&mut self, colour: C) -> &mut Self
[src]
Set the colour of the left-hand side of the embed.
This is an alias of colour
.
pub fn colour<C: Into<Colour>>(&mut self, colour: C) -> &mut Self
[src]
Set the colour of the left-hand side of the embed.
pub fn description<D: ToString>(&mut self, description: D) -> &mut Self
[src]
Set the description of the embed.
Note: This can't be longer than 2048 characters.
pub fn field<T, U>(&mut self, name: T, value: U, inline: bool) -> &mut Self where
T: ToString,
U: ToString,
[src]
T: ToString,
U: ToString,
Set a field. Note that this will not overwrite other fields, and will add to them.
Note: Maximum amount of characters you can put is 256 in a field name and 1024 in a field value.
pub fn fields<T, U, It>(&mut self, fields: It) -> &mut Self where
It: IntoIterator<Item = (T, U, bool)>,
T: ToString,
U: ToString,
[src]
It: IntoIterator<Item = (T, U, bool)>,
T: ToString,
U: ToString,
Adds multiple fields at once.
This is sugar to reduce the need of calling field
manually multiple times.
pub fn footer<F>(&mut self, f: F) -> &mut Self where
F: FnOnce(&mut CreateEmbedFooter) -> &mut CreateEmbedFooter,
[src]
F: FnOnce(&mut CreateEmbedFooter) -> &mut CreateEmbedFooter,
Set the footer of the embed.
Refer to the documentation for CreateEmbedFooter
for more
information.
pub fn image<S: ToString>(&mut self, url: S) -> &mut Self
[src]
Set the image associated with the embed. This only supports HTTP(S).
pub fn thumbnail<S: ToString>(&mut self, url: S) -> &mut Self
[src]
Set the thumbnail of the embed. This only supports HTTP(S).
pub fn timestamp<T: Into<Timestamp>>(&mut self, timestamp: T) -> &mut Self
[src]
Set the timestamp.
You may pass a direct string:
2017-01-03T23:00:00
2004-06-08T16:04:23
2004-06-08T16:04:23
This timestamp must be in ISO-8601 format. It must also be in UTC format.
You can also pass an instance of chrono::DateTime<Utc>
,
which will construct the timestamp string out of it.
Examples
Passing a string timestamp:
use serenity::prelude::*; use serenity::model::channel::Message; struct Handler; impl EventHandler for Handler { fn message(&self, context: Context, mut msg: Message) { if msg.content == "~embed" { let _ = msg.channel_id.send_message(&context.http, |m| { m.embed(|e| { e.title("hello").timestamp("2004-06-08T16:04:23") }); m }); } } } let mut client = Client::new("token", Handler).unwrap(); client.start().unwrap();
Creating a join-log:
Note: this example isn't efficient and is for demonstrative purposes.
use serenity::prelude::*; use serenity::model::guild::Member; use serenity::model::id::GuildId; struct Handler; impl EventHandler for Handler { fn guild_member_addition(&self, context: Context, guild_id: GuildId, member: Member) { let cache = context.cache.read(); if let Ok(guild) = guild_id.to_partial_guild(&context) { let channels = guild.channels(&context) .unwrap(); let channel_search = channels.values() .find(|c| c.name == "join-log"); if let Some(channel) = channel_search { let user = member.user.read(); let _ = channel.send_message(&context, |m| { m.embed(|e| { e.author(|a| { a.icon_url(&user.face()).name(&user.name) }); e.title("Member Join"); if let Some(ref joined_at) = member.joined_at { e.timestamp(joined_at); } e }) }); } } } } let mut client = Client::new("token", Handler).unwrap(); client.start().unwrap();
pub fn title<D: ToString>(&mut self, title: D) -> &mut Self
[src]
Set the title of the embed.
pub fn url<S: ToString>(&mut self, url: S) -> &mut Self
[src]
Set the URL to direct to when clicking on the title.
pub fn attachment<S: ToString>(&mut self, filename: S) -> &mut Self
[src]
Same as calling image
with "attachment://filename.(jpg, png)".
Note however, you have to be sure you set an attachment (with ChannelId::send_files
)
with the provided filename. Or else this won't work.
Trait Implementations
impl Clone for CreateEmbed
[src]
fn clone(&self) -> CreateEmbed
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for CreateEmbed
[src]
impl Default for CreateEmbed
[src]
fn default() -> CreateEmbed
[src]
Creates a builder with default values, setting the type
to rich
.
impl From<Embed> for CreateEmbed
[src]
Auto Trait Implementations
impl RefUnwindSafe for CreateEmbed
impl Send for CreateEmbed
impl Sync for CreateEmbed
impl Unpin for CreateEmbed
impl UnwindSafe for CreateEmbed
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CloneAny for T where
T: Clone + Any,
[src]
T: Clone + Any,
fn clone_any(&self) -> Box<dyn CloneAny + 'static>
[src]
fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send> where
T: Send,
[src]
T: Send,
fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync> where
T: Sync,
[src]
T: Sync,
fn clone_any_send_sync(&self) -> Box<dyn CloneAny + 'static + Sync + Send> where
T: Send + Sync,
[src]
T: Send + Sync,
impl<T> DebugAny for T where
T: Any + Debug,
[src]
T: Any + Debug,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,
impl<T> UnsafeAny for T where
T: Any,
T: Any,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,