[−][src]Struct twilight_embed_builder::builder::EmbedBuilder
Implementations
impl EmbedBuilder
[src]
pub const COLOR_MAXIMUM: u32
[src]
The maximum accepted color value.
This is used by color
.
pub const DESCRIPTION_LENGTH_LIMIT: usize
[src]
The maximum number of UTF-16 code points that can be in a description.
This is used by description
.
pub const EMBED_FIELD_LIMIT: usize
[src]
The maximum number of fields that can be in an embed.
This is used by build
.
pub const EMBED_LENGTH_LIMIT: usize
[src]
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.
This is used by build
.
pub const TITLE_LENGTH_LIMIT: usize
[src]
The maximum number of UTF-16 code points that can be in a title.
This is used by title
.
pub fn new() -> Self
[src]
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, EmbedBuildError>
[src]
Build this into an embed.
Errors
Returns EmbedBuildError::ContentTooLarge
if the textual content of
the embed is too large. Refer to EMBED_LENGTH_LIMIT
for the limit
value and what counts towards it.
Returns EmbedBuildError::TooManyFields
if there are too many fields
in the embed. Refer to EMBED_FIELD_LIMIT
for the limit value.
pub fn author(self, author: impl Into<EmbedAuthor>) -> Self
[src]
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();
pub fn color(self, color: u32) -> Result<Self, EmbedColorError>
[src]
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.
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();
Errors
Returns EmbedColorError::NotRgb
if the provided color is not a valid
RGB integer. Refer to COLOR_MAXIMUM
to know what the maximum
accepted value is.
Returns EmbedColorError::Zero
if the provided color is 0, which is not
an acceptable value.
pub fn description(
self,
description: impl Into<String>
) -> Result<Self, EmbedDescriptionError>
[src]
self,
description: impl Into<String>
) -> Result<Self, EmbedDescriptionError>
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();
Errors
Returns EmbedDescriptionError::TooLong
if the provided
description is longer than the maximum number of code points.
pub fn field(self, field: impl Into<EmbedField>) -> Self
[src]
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()?;
pub fn footer(self, footer: impl Into<EmbedFooter>) -> Self
[src]
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()?;
pub fn image(self, image_source: ImageSource) -> Self
[src]
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/trunk/logo.png")?; let embed = EmbedBuilder::new() .footer(EmbedFooterBuilder::new("twilight")?) .image(source) .build()?;
pub fn thumbnail(self, image_source: ImageSource) -> Self
[src]
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()?;
pub fn timestamp(self, timestamp: impl Into<String>) -> Self
[src]
Set the ISO 8601 timestamp.
pub fn title(self, title: impl Into<String>) -> Result<Self, EmbedTitleError>
[src]
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()?;
Errors
Returns EmbedTitleError::Empty
if the provided title is empty.
Returns EmbedTitleError::TooLong
if the provided title is longer
than the limit defined at TITLE_LENGTH_LIMIT
.
pub fn url(self, url: impl Into<String>) -> Self
[src]
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
impl Clone for EmbedBuilder
[src]
fn clone(&self) -> EmbedBuilder
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for EmbedBuilder
[src]
impl Default for EmbedBuilder
[src]
fn default() -> Self
[src]
Create an embed builder with a default embed.
All embeds have a "rich" type.
impl Eq for EmbedBuilder
[src]
impl PartialEq<EmbedBuilder> for EmbedBuilder
[src]
fn eq(&self, other: &EmbedBuilder) -> bool
[src]
fn ne(&self, other: &EmbedBuilder) -> bool
[src]
impl StructuralEq for EmbedBuilder
[src]
impl StructuralPartialEq for EmbedBuilder
[src]
impl TryFrom<EmbedBuilder> for Embed
[src]
type Error = EmbedBuildError
The type returned in the event of a conversion error.
fn try_from(builder: EmbedBuilder) -> Result<Self, Self::Error>
[src]
Convert an embed builder into an embed.
This is equivalent to calling EmbedBuilder::build
.
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,