EmbedBuilder

Struct EmbedBuilder 

Source
pub struct EmbedBuilder(/* private fields */);
๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed
Expand description

Create an embed with a builder.

ยงExamples

Refer to the crate-level documentation for examples.

Implementationsยง

Sourceยง

impl EmbedBuilder

Source

pub const AUTHOR_NAME_LENGTH_LIMIT: usize = 256usize

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

The maximum number of UTF-16 code points that can be in an author name.

Source

pub const COLOR_MAXIMUM: u32 = 16_777_215u32

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

The maximum accepted color value.

Source

pub const DESCRIPTION_LENGTH_LIMIT: usize = 4_096usize

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

The maximum number of UTF-16 code points that can be in a description.

Source

pub const EMBED_FIELD_LIMIT: usize = 25usize

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

The maximum number of fields that can be in an embed.

Source

pub const EMBED_LENGTH_LIMIT: usize = 6_000usize

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

The maximum total textual length of the embed in UTF-16 code points.

This combines the text of the author name, description, footer text, field names and values, and title.

Source

pub const FIELD_NAME_LENGTH_LIMIT: usize = 256usize

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

The maximum number of UTF-16 code points that can be in a field name.

Source

pub const FIELD_VALUE_LENGTH_LIMIT: usize = 1_024usize

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

The maximum number of UTF-16 code points that can be in a field value.

Source

pub const FOOTER_TEXT_LENGTH_LIMIT: usize = 2_048usize

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

The maximum number of UTF-16 code points that can be in a footerโ€™s text.

Source

pub const TITLE_LENGTH_LIMIT: usize = 256usize

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

The maximum number of UTF-16 code points that can be in a title.

Source

pub const fn new() -> Self

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

Create a new default embed builder.

See the crate-level documentation for examples and additional information.

This is equivalent to the default implementation.

Source

pub fn build(self) -> Result<Embed, EmbedError>

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

Build this into an embed.

ยงErrors

Returns an EmbedErrorType::AuthorNameEmpty error type if the provided name is empty.

Returns an EmbedErrorType::AuthorNameTooLong error type if the provided name is longer than AUTHOR_NAME_LENGTH_LIMIT.

Returns an EmbedErrorType::ColorNotRgb error type if the provided color is not a valid RGB integer. Refer to COLOR_MAXIMUM to know what the maximum accepted value is.

Returns an EmbedErrorType::ColorZero error type if the provided color is 0, which is not an acceptable value.

Returns an EmbedErrorType::DescriptionEmpty error type if a provided description is empty.

Returns an EmbedErrorType::DescriptionTooLong error type if a provided description is longer than DESCRIPTION_LENGTH_LIMIT.

Returns an EmbedErrorType::FieldNameEmpty error type if a provided field name is empty.

Returns an EmbedErrorType::FieldNameTooLong error type if a provided field name is longer than FIELD_NAME_LENGTH_LIMIT.

Returns an EmbedErrorType::FieldValueEmpty error type if a provided field value is empty.

Returns an EmbedErrorType::FieldValueTooLong error type if a provided field value is longer than FIELD_VALUE_LENGTH_LIMIT.

Returns an EmbedErrorType::FooterTextEmpty error type if the provided text is empty.

Returns an EmbedErrorType::FooterTextTooLong error type if the provided text is longer than the limit defined at FOOTER_TEXT_LENGTH_LIMIT.

Returns an EmbedErrorType::TitleEmpty error type if the provided title is empty.

Returns an EmbedErrorType::TitleTooLong error type if the provided text is longer than the limit defined at TITLE_LENGTH_LIMIT.

Returns an EmbedErrorType::TooManyFields error type if there are too many fields in the embed. Refer to EMBED_FIELD_LIMIT for the limit value.

Returns an EmbedErrorType::TotalContentTooLarge error type if the textual content of the embed is too large. Refer to EMBED_LENGTH_LIMIT for the limit value and what counts towards it.

Source

pub fn author(self, author: impl Into<EmbedAuthor>) -> Self

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

Set the author.

ยงExamples

Create an embed author:

use twilight_embed_builder::{EmbedAuthorBuilder, EmbedBuilder};

let author = EmbedAuthorBuilder::new("Twilight".into())
    .url("https://github.com/twilight-rs/twilight")
    .build();

let embed = EmbedBuilder::new().author(author).build()?;
Source

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

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

Set the color.

This must be a valid hexadecimal RGB value. 0x000000 is not an acceptable value as it would be thrown out by Discord. Refer to COLOR_MAXIMUM for the maximum acceptable value.

ยงExamples

Set the color of an embed to 0xfd69b3:

use twilight_embed_builder::EmbedBuilder;

let embed = EmbedBuilder::new()
    .color(0xfd_69_b3)
    .description("a description")
    .build()?;
Source

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

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

Set the description.

Refer to DESCRIPTION_LENGTH_LIMIT for the maximum number of UTF-16 code points that can be in a description.

ยงExamples
use twilight_embed_builder::EmbedBuilder;

let embed = EmbedBuilder::new().description("this is an embed").build()?;
Source

pub fn field(self, field: impl Into<EmbedField>) -> Self

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

Add a field to the embed.

ยงExamples
use twilight_embed_builder::{EmbedBuilder, EmbedFieldBuilder};

let embed = EmbedBuilder::new()
    .description("this is an embed")
    .field(EmbedFieldBuilder::new("a field", "and its value"))
    .build()?;
Source

pub fn footer(self, footer: impl Into<EmbedFooter>) -> Self

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

Set the footer of the embed.

ยงExamples
use twilight_embed_builder::{EmbedBuilder, EmbedFooterBuilder};

let embed = EmbedBuilder::new()
    .description("this is an embed")
    .footer(EmbedFooterBuilder::new("a footer"))
    .build()?;
Source

pub fn image(self, image_source: ImageSource) -> Self

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

Set the image.

ยงExamples

Set the image source to a URL:

use twilight_embed_builder::{EmbedBuilder, EmbedFooterBuilder, ImageSource};

let source = ImageSource::url("https://raw.githubusercontent.com/twilight-rs/twilight/main/logo.png")?;
let embed = EmbedBuilder::new()
    .footer(EmbedFooterBuilder::new("twilight"))
    .image(source)
    .build()?;
Source

pub fn thumbnail(self, image_source: ImageSource) -> Self

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

Add a thumbnail.

ยงExamples

Set the thumbnail to an image attachment with the filename "twilight.png":

use twilight_embed_builder::{EmbedBuilder, ImageSource};

let embed = EmbedBuilder::new()
    .description("a picture of twilight")
    .thumbnail(ImageSource::attachment("twilight.png")?)
    .build()?;
Source

pub const fn timestamp(self, timestamp: Timestamp) -> Self

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

Set the ISO 8601 timestamp.

Source

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

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

Set the title.

Refer to TITLE_LENGTH_LIMIT for the maximum number of UTF-16 code points that can be in a title.

ยงExamples

Set the title to โ€œtwilightโ€:

use twilight_embed_builder::EmbedBuilder;

let embed = EmbedBuilder::new()
    .title("twilight")
    .url("https://github.com/twilight-rs/twilight")
    .build()?;
Source

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

๐Ÿ‘ŽDeprecated since 0.10.1: use twilight_util::builder::embed

Set the URL.

ยงExamples

Set the URL to twilightโ€™s repository:

use twilight_embed_builder::{EmbedBuilder, EmbedFooterBuilder};

let embed = EmbedBuilder::new()
    .description("twilight's repository")
    .url("https://github.com/twilight-rs/twilight")
    .build()?;

Trait Implementationsยง

Sourceยง

impl Clone for EmbedBuilder

Sourceยง

fn clone(&self) -> EmbedBuilder

Returns a duplicate of the value. Read more
1.0.0 ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Sourceยง

impl Debug for EmbedBuilder

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl Default for EmbedBuilder

Sourceยง

fn default() -> Self

Create an embed builder with a default embed.

All embeds have a โ€œrichโ€ type.

Sourceยง

impl PartialEq for EmbedBuilder

Sourceยง

fn eq(&self, other: &EmbedBuilder) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท Sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Sourceยง

impl TryFrom<EmbedBuilder> for Embed

Sourceยง

fn try_from(builder: EmbedBuilder) -> Result<Self, Self::Error>

Convert an embed builder into an embed.

This is equivalent to calling EmbedBuilder::build.

Sourceยง

type Error = EmbedError

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

impl Eq for EmbedBuilder

Sourceยง

impl StructuralPartialEq for EmbedBuilder

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> CloneToUninit for T
where T: Clone,

Sourceยง

unsafe fn clone_to_uninit(&self, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Sourceยง

type Owned = T

The resulting type after obtaining ownership.
Sourceยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Sourceยง

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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