Struct twilight_embed_builder::EmbedBuilder [−][src]
#[must_use = "must be built into an embed"]pub struct EmbedBuilder(_);
Expand description
Implementations
The maximum number of UTF-16 code points that can be in an author name.
The maximum accepted color value.
The maximum number of UTF-16 code points that can be in a description.
The maximum number of fields that can be in an 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.
The maximum number of UTF-16 code points that can be in a field name.
The maximum number of UTF-16 code points that can be in a field value.
The maximum number of UTF-16 code points that can be in a footer’s text.
The maximum number of UTF-16 code points that can be in a title.
Create a new default embed builder.
See the crate-level documentation for examples and additional information.
This is equivalent to the default implementation.
#[must_use = "should be used as part of something like a message"]pub fn build(self) -> Result<Embed, EmbedError>[src]
#[must_use = "should be used as part of something like a message"]pub fn build(self) -> Result<Embed, EmbedError>[src]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.
Set the author.
Examples
Create an embed author:
use twilight_embed_builder::{EmbedAuthorBuilder, EmbedBuilder}; let author = EmbedAuthorBuilder::new() .name("Twilight") .url("https://github.com/twilight-rs/twilight") .build(); let embed = EmbedBuilder::new().author(author).build()?;
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()?;
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()?;
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()?;
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()?;
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()?;
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()?;
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()?;
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
This method tests for self and other values to be equal, and is used
by ==. Read more
This method tests for !=.
Auto Trait Implementations
impl RefUnwindSafe for EmbedBuilderimpl Send for EmbedBuilderimpl Sync for EmbedBuilderimpl Unpin for EmbedBuilderimpl UnwindSafe for EmbedBuilderBlanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more