[][src]Struct twilight_builders::embed::EmbedBuilder

#[must_use =
  "The embed is not constructed. You need to call build to construct the embed."]pub struct EmbedBuilder(_);

Create an embed via a builder.

If uploading an image as an attachment, set as the image or thumbnail with attachment://{filename}.{extension}. Refer to the discord docs for more information.

Examples

A simple embed:

use twilight_builders::embed::EmbedBuilder;

let embed = EmbedBuilder::new()
    .description("Here's a list of reasons why Twilight is the best pony:")
    .add_field("Wings", "She has wings.")
        .inline()
        .commit()
    .add_field("Horn", "She can do magic, and she's really good at it.")
        .commit()
    .build();

An embed with images:

use twilight_builders::embed::EmbedBuilder;

let embed = EmbedBuilder::new()
    .description("Here's a cool image of Twilight Sparkle")
    .image("attachment://bestpony.png")
    .build();

Implementations

impl EmbedBuilder[src]

pub fn new() -> Self[src]

pub fn author(self) -> AuthorBuilder[src]

Return a new AuthorBuilder.

pub fn color(self, color: u32) -> Self[src]

Set the color.

Use hexadecimal syntax to specify an integer: 0xD4A4E8

pub fn description(self, description: impl Into<String>) -> Self[src]

Set the description.

Limited to 2048 UTF-16 code points.

pub fn add_field(
    self,
    name: impl Into<String>,
    value: impl Into<String>
) -> FieldBuilder
[src]

Add a field with a new FieldBuilder.

The name is limited to 256 UTF-16 code points, and the value is limited to 1024. The amount of fields is limited to 25.

pub fn footer(self, text: impl Into<String>) -> FooterBuilder[src]

Return a new FooterBuilder.

The text is limited to 2048 UTF-16 code points.

pub fn image(self, url: impl Into<String>) -> Self[src]

Add an image.

Either the URL to an image or an attachment:// path.

pub fn thumbnail(self, url: impl Into<String>) -> Self[src]

Add a thumbnail.

Either the URL to an image or an attachment:// path.

pub fn timestamp(self, timestamp: impl Into<String>) -> Self[src]

Set the ISO 8601 timestamp.

pub fn title(self, title: impl Into<String>) -> Self[src]

Set the title.

Limited to 256 UTF-16 code points.

pub fn url(self, url: impl Into<String>) -> Self[src]

Set the URL.

pub fn build(self) -> Embed[src]

Return an Embed.

Trait Implementations

impl Clone for EmbedBuilder[src]

impl Debug for EmbedBuilder[src]

impl Default for EmbedBuilder[src]

Auto Trait Implementations

impl RefUnwindSafe for EmbedBuilder

impl Send for EmbedBuilder

impl Sync for EmbedBuilder

impl Unpin for EmbedBuilder

impl UnwindSafe for EmbedBuilder

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> From<T> for T[src]

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

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.