[−][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]
impl CreateEmbed
Set the author of the embed.
Refer to the documentation for CreateEmbedAuthor
for more
information.
pub fn color<C: Into<Colour>>(self, colour: C) -> Self
[src]
pub fn color<C: Into<Colour>>(self, colour: C) -> Self
Set the colour of the left-hand side of the embed.
This is an alias of colour
.
pub fn colour<C: Into<Colour>>(self, colour: C) -> Self
[src]
pub fn colour<C: Into<Colour>>(self, colour: C) -> Self
Set the colour of the left-hand side of the embed.
pub fn description<D: Display>(self, description: D) -> Self
[src]
pub fn description<D: Display>(self, description: D) -> Self
Set the description of the embed.
Note: This can't be longer than 2048 characters.
pub fn field<T, U>(self, name: T, value: U, inline: bool) -> Self where
T: Display,
U: Display,
[src]
pub fn field<T, U>(self, name: T, value: U, inline: bool) -> Self where
T: Display,
U: Display,
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>(self, fields: It) -> Self where
It: IntoIterator<Item = (T, U, bool)>,
T: Display,
U: Display,
[src]
pub fn fields<T, U, It>(self, fields: It) -> Self where
It: IntoIterator<Item = (T, U, bool)>,
T: Display,
U: Display,
Adds multiple fields at once.
This is sugar to reduce the need of calling field
manually multiple times.
Set the footer of the embed.
Refer to the documentation for CreateEmbedFooter
for more
information.
pub fn image<S: AsRef<str>>(self, url: S) -> Self
[src]
pub fn image<S: AsRef<str>>(self, url: S) -> Self
Set the image associated with the embed. This only supports HTTP(S).
pub fn thumbnail<S: AsRef<str>>(self, url: S) -> Self
[src]
pub fn thumbnail<S: AsRef<str>>(self, url: S) -> Self
Set the thumbnail of the embed. This only supports HTTP(S).
pub fn timestamp<T: Into<Timestamp>>(self, timestamp: T) -> Self
[src]
pub fn timestamp<T: Into<Timestamp>>(self, timestamp: T) -> Self
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 anything that implements chrono::TimeZone
.
Examples
Passing a string timestamp:
use serenity::prelude::*; use serenity::model::channel::Message; struct Handler; impl EventHandler for Handler { fn message(&self, _: Context, msg: Message) { if msg.content == "~embed" { let _ = msg.channel_id.send_message(|m| m .embed(|e| e .title("hello") .timestamp("2004-06-08T16:04:23"))); } } } 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, guild_id: GuildId, member: Member) { use serenity::CACHE; let cache = CACHE.read(); if let Some(guild) = cache.guild(guild_id) { let guild = guild.read(); let channel_search = guild .channels .values() .find(|c| c.read().name == "join-log"); if let Some(channel) = channel_search { let user = member.user.read(); let _ = channel.read().send_message(|m| m .embed(|e| { let mut e = e .author(|a| a.icon_url(&user.face()).name(&user.name)) .title("Member Join"); if let Some(ref joined_at) = member.joined_at { e = e.timestamp(joined_at); } e })); } } } } let mut client = Client::new("token", Handler).unwrap(); client.start().unwrap();
pub fn title<D: Display>(self, title: D) -> Self
[src]
pub fn title<D: Display>(self, title: D) -> Self
Set the title of the embed.
pub fn url<S: AsRef<str>>(self, url: S) -> Self
[src]
pub fn url<S: AsRef<str>>(self, url: S) -> Self
Set the URL to direct to when clicking on the title.
pub fn attachment<S: AsRef<str>>(self, filename: S) -> Self
[src]
pub fn attachment<S: AsRef<str>>(self, filename: S) -> Self
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 Default for CreateEmbed
[src]
impl Default for CreateEmbed
fn default() -> CreateEmbed
[src]
fn default() -> CreateEmbed
Creates a builder with default values, setting the type
to rich
.
impl From<Embed> for CreateEmbed
[src]
impl From<Embed> for CreateEmbed
fn from(embed: Embed) -> CreateEmbed
[src]
fn from(embed: Embed) -> CreateEmbed
Converts the fields of an embed into the values for a new embed builder.
Some values - such as Proxy URLs - are not preserved.
impl Clone for CreateEmbed
[src]
impl Clone for CreateEmbed
fn clone(&self) -> CreateEmbed
[src]
fn clone(&self) -> CreateEmbed
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for CreateEmbed
[src]
impl Debug for CreateEmbed
Auto Trait Implementations
impl Send for CreateEmbed
impl Send for CreateEmbed
impl Sync for CreateEmbed
impl Sync for CreateEmbed
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> Erased for T
impl<T> Erased for T
impl<T> Typeable for T where
T: Any,
impl<T> Typeable for T where
T: Any,
impl<T> DebugAny for T where
T: Any + Debug,
[src]
impl<T> DebugAny for T where
T: Any + Debug,
impl<T> CloneAny for T where
T: Clone + Any,
[src]
impl<T> CloneAny for T where
T: Clone + Any,
fn clone_any(&self) -> Box<dyn CloneAny + 'static>
[src]
fn clone_any(&self) -> Box<dyn CloneAny + 'static>
fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send> where
T: Send,
[src]
fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send> where
T: Send,
fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync> where
T: Sync,
[src]
fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync> where
T: Sync,
fn clone_any_send_sync(&self) -> Box<dyn CloneAny + 'static + Sync + Send> where
T: Send + Sync,
[src]
fn clone_any_send_sync(&self) -> Box<dyn CloneAny + 'static + Sync + Send> where
T: Send + Sync,
impl<T> UnsafeAny for T where
T: Any,
impl<T> UnsafeAny for T where
T: Any,