Skip to main content

EmbedAuthorBuilder

Struct EmbedAuthorBuilder 

Source
pub struct EmbedAuthorBuilder { /* private fields */ }
Expand description

Builds the author of an embed — a name with an optional link and icon — for EmbedBuilder::author.

A plain name converts into it, so .author("Bot") is enough when there is no link or icon. EmbedBuilder::build checks it as part of the embed; build checks it on its own.

discord.js counterpart: the EmbedAuthorOptions passed to EmbedBuilder#setAuthor.

§Examples

use djs_builders::{EmbedAuthorBuilder, EmbedBuilder};

let embed = EmbedBuilder::new()
    .author(EmbedAuthorBuilder::new("Ada").icon_url("https://example.com/ada.png"))
    .build()
    .unwrap();
assert_eq!(embed.author.unwrap().icon_url.as_deref(), Some("https://example.com/ada.png"));

Implementations§

Source§

impl EmbedAuthorBuilder

Source

pub fn new(name: impl Into<CompactString>) -> Self

Creates an author named name (at most 256 characters).

discord.js counterpart: the name of EmbedAuthorOptions, given to EmbedBuilder#setAuthor.

Source

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

Sets the URL the name links to (http:// or https://; not attachment://).

discord.js counterpart: the url of EmbedAuthorOptions.

Source

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

Sets the icon shown before the name: a link (http://, https://) or an uploaded file (attachment://name.png).

discord.js counterpart: the iconURL of EmbedAuthorOptions.

Source

pub fn build(self) -> Result<EmbedAuthor, ValidationError>

Checks the author on its own and returns it; the paths in a ValidationError are name, url and icon_url.

discord.js counterpart: EmbedAuthorOptions, checked by EmbedBuilder#setAuthor.

§Errors

ValidationError::TooLong for a name above 256 characters, ValidationError::InvalidUrl for a URL with a scheme Discord does not allow.

Source

pub fn build_unchecked(self) -> EmbedAuthor

Returns the author without any check (D-180).

discord.js counterpart: EmbedAuthorOptions with validation off (disableValidators).

Trait Implementations§

Source§

impl Clone for EmbedAuthorBuilder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for EmbedAuthorBuilder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for EmbedAuthorBuilder

Source§

impl From<&String> for EmbedAuthorBuilder

Source§

fn from(text: &String) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for EmbedAuthorBuilder

Source§

fn from(text: &str) -> Self

Converts to this type from the input type.
Source§

impl From<CompactString> for EmbedAuthorBuilder

Source§

fn from(text: CompactString) -> Self

Converts to this type from the input type.
Source§

impl From<EmbedAuthor> for EmbedAuthorBuilder

Source§

fn from(author: EmbedAuthor) -> Self

Converts to this type from the input type.
Source§

impl From<String> for EmbedAuthorBuilder

Source§

fn from(text: String) -> Self

Converts to this type from the input type.
Source§

impl Hash for EmbedAuthorBuilder

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for EmbedAuthorBuilder

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for EmbedAuthorBuilder

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, 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.