Struct twilight_embed_builder::EmbedBuilder
source · [−]pub struct EmbedBuilder(_);
use twilight_util::builder::embed
Expand description
Implementations
sourceimpl EmbedBuilder
impl EmbedBuilder
sourcepub const AUTHOR_NAME_LENGTH_LIMIT: usize = 256usize
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub const AUTHOR_NAME_LENGTH_LIMIT: usize = 256usize
use twilight_util::builder::embed
The maximum number of UTF-16 code points that can be in an author name.
sourcepub const COLOR_MAXIMUM: u32 = 16_777_215u32
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub const COLOR_MAXIMUM: u32 = 16_777_215u32
use twilight_util::builder::embed
The maximum accepted color value.
sourcepub const DESCRIPTION_LENGTH_LIMIT: usize = 4_096usize
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub const DESCRIPTION_LENGTH_LIMIT: usize = 4_096usize
use twilight_util::builder::embed
The maximum number of UTF-16 code points that can be in a description.
sourcepub const EMBED_FIELD_LIMIT: usize = 25usize
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub const EMBED_FIELD_LIMIT: usize = 25usize
use twilight_util::builder::embed
The maximum number of fields that can be in an embed.
sourcepub const EMBED_LENGTH_LIMIT: usize = 6_000usize
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub const EMBED_LENGTH_LIMIT: usize = 6_000usize
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.
sourcepub const FIELD_NAME_LENGTH_LIMIT: usize = 256usize
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub const FIELD_NAME_LENGTH_LIMIT: usize = 256usize
use twilight_util::builder::embed
The maximum number of UTF-16 code points that can be in a field name.
sourcepub const FIELD_VALUE_LENGTH_LIMIT: usize = 1_024usize
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub const FIELD_VALUE_LENGTH_LIMIT: usize = 1_024usize
use twilight_util::builder::embed
The maximum number of UTF-16 code points that can be in a field value.
sourcepub const FOOTER_TEXT_LENGTH_LIMIT: usize = 2_048usize
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub const FOOTER_TEXT_LENGTH_LIMIT: usize = 2_048usize
use twilight_util::builder::embed
The maximum number of UTF-16 code points that can be in a footer’s text.
sourcepub const TITLE_LENGTH_LIMIT: usize = 256usize
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub const TITLE_LENGTH_LIMIT: usize = 256usize
use twilight_util::builder::embed
The maximum number of UTF-16 code points that can be in a title.
sourcepub const fn new() -> Self
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub const fn new() -> Self
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.
sourcepub fn build(self) -> Result<Embed, EmbedError>
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub fn build(self) -> Result<Embed, EmbedError>
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.
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
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()?;
sourcepub fn color(self, color: u32) -> Self
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub fn color(self, color: u32) -> Self
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()?;
sourcepub fn description(self, description: impl Into<String>) -> Self
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub fn description(self, description: impl Into<String>) -> Self
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()?;
sourcepub fn field(self, field: impl Into<EmbedField>) -> Self
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub fn field(self, field: impl Into<EmbedField>) -> Self
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()?;
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
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()?;
sourcepub fn image(self, image_source: ImageSource) -> Self
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub fn image(self, image_source: ImageSource) -> Self
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()?;
sourcepub fn thumbnail(self, image_source: ImageSource) -> Self
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub fn thumbnail(self, image_source: ImageSource) -> Self
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()?;
sourcepub const fn timestamp(self, timestamp: Timestamp) -> Self
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub const fn timestamp(self, timestamp: Timestamp) -> Self
use twilight_util::builder::embed
Set the ISO 8601 timestamp.
sourcepub fn title(self, title: impl Into<String>) -> Self
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub fn title(self, title: impl Into<String>) -> Self
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()?;
sourcepub fn url(self, url: impl Into<String>) -> Self
👎 Deprecated since 0.10.1: use twilight_util::builder::embed
pub fn url(self, url: impl Into<String>) -> Self
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
sourceimpl Clone for EmbedBuilder
impl Clone for EmbedBuilder
sourcefn clone(&self) -> EmbedBuilder
fn clone(&self) -> EmbedBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for EmbedBuilder
impl Debug for EmbedBuilder
sourceimpl Default for EmbedBuilder
impl Default for EmbedBuilder
sourceimpl PartialEq<EmbedBuilder> for EmbedBuilder
impl PartialEq<EmbedBuilder> for EmbedBuilder
sourcefn eq(&self, other: &EmbedBuilder) -> bool
fn eq(&self, other: &EmbedBuilder) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &EmbedBuilder) -> bool
fn ne(&self, other: &EmbedBuilder) -> bool
This method tests for !=
.
sourceimpl TryFrom<EmbedBuilder> for Embed
impl TryFrom<EmbedBuilder> for Embed
sourcefn try_from(builder: EmbedBuilder) -> Result<Self, Self::Error>
fn try_from(builder: EmbedBuilder) -> Result<Self, Self::Error>
Convert an embed builder into an embed.
This is equivalent to calling EmbedBuilder::build
.
type Error = EmbedError
type Error = EmbedError
The type returned in the event of a conversion error.
impl Eq for EmbedBuilder
impl StructuralEq for EmbedBuilder
impl StructuralPartialEq for EmbedBuilder
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more