pub struct EmbedBuilder(/* private fields */);
Expand description
Implementationsยง
Sourceยงimpl 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
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
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
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
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
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
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
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
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
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
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>
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
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
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
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
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
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
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
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
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
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
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
impl Clone for EmbedBuilder
Sourceยงfn clone(&self) -> EmbedBuilder
fn clone(&self) -> EmbedBuilder
1.0.0 ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSourceยงimpl Debug for EmbedBuilder
impl Debug for EmbedBuilder
Sourceยงimpl Default for EmbedBuilder
impl Default for EmbedBuilder
Sourceยงimpl PartialEq for EmbedBuilder
impl PartialEq for EmbedBuilder
Sourceยงimpl TryFrom<EmbedBuilder> for Embed
impl TryFrom<EmbedBuilder> for Embed
Sourceยงfn 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
.