WebHookEmbed

Struct WebHookEmbed 

Source
pub struct WebHookEmbed {
    pub title: Option<String>,
    pub description: Option<String>,
    pub color: Option<u32>,
    pub author: Option<WebHookEmbedAuthor>,
    pub fields: Option<Vec<WebHookEmbedField>>,
    pub footer: Option<WebHookEmbedFooter>,
    pub image: Option<WebHookEmbedImage>,
    pub thumbnail: Option<WebHookEmbedThumbnail>,
}

Fields§

§title: Option<String>§description: Option<String>§color: Option<u32>§author: Option<WebHookEmbedAuthor>§fields: Option<Vec<WebHookEmbedField>>§footer: Option<WebHookEmbedFooter>§image: Option<WebHookEmbedImage>§thumbnail: Option<WebHookEmbedThumbnail>

Implementations§

Source§

impl WebHookEmbed

Source

pub fn new() -> WebHookEmbed

Source

pub fn title<T: AsRef<str>>(self, title: T) -> WebHookEmbed

Examples found in repository?
examples/webhook.rs (line 11)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    let secret = "webhook_key";
6    webhook::new(secret, |x| {
7        x.content("Hello, World!")
8            .username("Rusty WebHook")
9            .avatar_url("https://avatars.githubusercontent.com/u/74909209")
10            .embed(|e| {
11                e.title("Embed Title")
12                    .description("Embed Description")
13                    .thumbnail("https://avatars.githubusercontent.com/u/5430905")
14                    .author(|a| {
15                        a.name("Author Name")
16                            .icon_url("https://avatars.githubusercontent.com/u/9919")
17                    })
18                    .color(15258703)
19                    .image("https://i.imgur.com/nBeX2Y3.jpg")
20                    .footer(|f| f.text("Footer").icon_url("https://i.imgur.com/vk1RYK4.png"))
21                    .add_field("Field 1", "Value 1", false)
22                    .add_field("Field 2", "Value 2", false)
23            })
24    })
25    .send()
26    .await?;
27
28    Ok(())
29}
Source

pub fn description<T: AsRef<str>>(self, description: T) -> WebHookEmbed

Examples found in repository?
examples/webhook.rs (line 12)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    let secret = "webhook_key";
6    webhook::new(secret, |x| {
7        x.content("Hello, World!")
8            .username("Rusty WebHook")
9            .avatar_url("https://avatars.githubusercontent.com/u/74909209")
10            .embed(|e| {
11                e.title("Embed Title")
12                    .description("Embed Description")
13                    .thumbnail("https://avatars.githubusercontent.com/u/5430905")
14                    .author(|a| {
15                        a.name("Author Name")
16                            .icon_url("https://avatars.githubusercontent.com/u/9919")
17                    })
18                    .color(15258703)
19                    .image("https://i.imgur.com/nBeX2Y3.jpg")
20                    .footer(|f| f.text("Footer").icon_url("https://i.imgur.com/vk1RYK4.png"))
21                    .add_field("Field 1", "Value 1", false)
22                    .add_field("Field 2", "Value 2", false)
23            })
24    })
25    .send()
26    .await?;
27
28    Ok(())
29}
Source

pub fn color(self, color: u32) -> WebHookEmbed

Examples found in repository?
examples/webhook.rs (line 18)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    let secret = "webhook_key";
6    webhook::new(secret, |x| {
7        x.content("Hello, World!")
8            .username("Rusty WebHook")
9            .avatar_url("https://avatars.githubusercontent.com/u/74909209")
10            .embed(|e| {
11                e.title("Embed Title")
12                    .description("Embed Description")
13                    .thumbnail("https://avatars.githubusercontent.com/u/5430905")
14                    .author(|a| {
15                        a.name("Author Name")
16                            .icon_url("https://avatars.githubusercontent.com/u/9919")
17                    })
18                    .color(15258703)
19                    .image("https://i.imgur.com/nBeX2Y3.jpg")
20                    .footer(|f| f.text("Footer").icon_url("https://i.imgur.com/vk1RYK4.png"))
21                    .add_field("Field 1", "Value 1", false)
22                    .add_field("Field 2", "Value 2", false)
23            })
24    })
25    .send()
26    .await?;
27
28    Ok(())
29}
Source

pub fn image<T: AsRef<str>>(self, url: T) -> WebHookEmbed

Examples found in repository?
examples/webhook.rs (line 19)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    let secret = "webhook_key";
6    webhook::new(secret, |x| {
7        x.content("Hello, World!")
8            .username("Rusty WebHook")
9            .avatar_url("https://avatars.githubusercontent.com/u/74909209")
10            .embed(|e| {
11                e.title("Embed Title")
12                    .description("Embed Description")
13                    .thumbnail("https://avatars.githubusercontent.com/u/5430905")
14                    .author(|a| {
15                        a.name("Author Name")
16                            .icon_url("https://avatars.githubusercontent.com/u/9919")
17                    })
18                    .color(15258703)
19                    .image("https://i.imgur.com/nBeX2Y3.jpg")
20                    .footer(|f| f.text("Footer").icon_url("https://i.imgur.com/vk1RYK4.png"))
21                    .add_field("Field 1", "Value 1", false)
22                    .add_field("Field 2", "Value 2", false)
23            })
24    })
25    .send()
26    .await?;
27
28    Ok(())
29}
Source

pub fn thumbnail<T: AsRef<str>>(self, url: T) -> WebHookEmbed

Examples found in repository?
examples/webhook.rs (line 13)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    let secret = "webhook_key";
6    webhook::new(secret, |x| {
7        x.content("Hello, World!")
8            .username("Rusty WebHook")
9            .avatar_url("https://avatars.githubusercontent.com/u/74909209")
10            .embed(|e| {
11                e.title("Embed Title")
12                    .description("Embed Description")
13                    .thumbnail("https://avatars.githubusercontent.com/u/5430905")
14                    .author(|a| {
15                        a.name("Author Name")
16                            .icon_url("https://avatars.githubusercontent.com/u/9919")
17                    })
18                    .color(15258703)
19                    .image("https://i.imgur.com/nBeX2Y3.jpg")
20                    .footer(|f| f.text("Footer").icon_url("https://i.imgur.com/vk1RYK4.png"))
21                    .add_field("Field 1", "Value 1", false)
22                    .add_field("Field 2", "Value 2", false)
23            })
24    })
25    .send()
26    .await?;
27
28    Ok(())
29}
Source

pub fn author<F>(self, author: F) -> WebHookEmbed

Examples found in repository?
examples/webhook.rs (lines 14-17)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    let secret = "webhook_key";
6    webhook::new(secret, |x| {
7        x.content("Hello, World!")
8            .username("Rusty WebHook")
9            .avatar_url("https://avatars.githubusercontent.com/u/74909209")
10            .embed(|e| {
11                e.title("Embed Title")
12                    .description("Embed Description")
13                    .thumbnail("https://avatars.githubusercontent.com/u/5430905")
14                    .author(|a| {
15                        a.name("Author Name")
16                            .icon_url("https://avatars.githubusercontent.com/u/9919")
17                    })
18                    .color(15258703)
19                    .image("https://i.imgur.com/nBeX2Y3.jpg")
20                    .footer(|f| f.text("Footer").icon_url("https://i.imgur.com/vk1RYK4.png"))
21                    .add_field("Field 1", "Value 1", false)
22                    .add_field("Field 2", "Value 2", false)
23            })
24    })
25    .send()
26    .await?;
27
28    Ok(())
29}
Source

pub fn footer<F>(self, footer: F) -> WebHookEmbed

Examples found in repository?
examples/webhook.rs (line 20)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    let secret = "webhook_key";
6    webhook::new(secret, |x| {
7        x.content("Hello, World!")
8            .username("Rusty WebHook")
9            .avatar_url("https://avatars.githubusercontent.com/u/74909209")
10            .embed(|e| {
11                e.title("Embed Title")
12                    .description("Embed Description")
13                    .thumbnail("https://avatars.githubusercontent.com/u/5430905")
14                    .author(|a| {
15                        a.name("Author Name")
16                            .icon_url("https://avatars.githubusercontent.com/u/9919")
17                    })
18                    .color(15258703)
19                    .image("https://i.imgur.com/nBeX2Y3.jpg")
20                    .footer(|f| f.text("Footer").icon_url("https://i.imgur.com/vk1RYK4.png"))
21                    .add_field("Field 1", "Value 1", false)
22                    .add_field("Field 2", "Value 2", false)
23            })
24    })
25    .send()
26    .await?;
27
28    Ok(())
29}
Source

pub fn add_field<T: AsRef<str>>( self, name: T, value: T, inline: bool, ) -> WebHookEmbed

Examples found in repository?
examples/webhook.rs (line 21)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    let secret = "webhook_key";
6    webhook::new(secret, |x| {
7        x.content("Hello, World!")
8            .username("Rusty WebHook")
9            .avatar_url("https://avatars.githubusercontent.com/u/74909209")
10            .embed(|e| {
11                e.title("Embed Title")
12                    .description("Embed Description")
13                    .thumbnail("https://avatars.githubusercontent.com/u/5430905")
14                    .author(|a| {
15                        a.name("Author Name")
16                            .icon_url("https://avatars.githubusercontent.com/u/9919")
17                    })
18                    .color(15258703)
19                    .image("https://i.imgur.com/nBeX2Y3.jpg")
20                    .footer(|f| f.text("Footer").icon_url("https://i.imgur.com/vk1RYK4.png"))
21                    .add_field("Field 1", "Value 1", false)
22                    .add_field("Field 2", "Value 2", false)
23            })
24    })
25    .send()
26    .await?;
27
28    Ok(())
29}

Trait Implementations§

Source§

impl Debug for WebHookEmbed

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deserialize for WebHookEmbed

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for WebHookEmbed

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToJson for T
where T: Serialize + ?Sized,

Source§

fn to_json(&self) -> Result<Value, Error>

Represent self as a serde_json::Value. Note that Value is not a JSON string. If you need a string, use serde_json::to_string instead. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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