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
impl EmbedAuthorBuilder
Sourcepub fn new(name: impl Into<CompactString>) -> Self
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.
Sourcepub fn url(self, url: impl Into<CompactString>) -> Self
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.
Sourcepub fn icon_url(self, url: impl Into<CompactString>) -> Self
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.
Sourcepub fn build(self) -> Result<EmbedAuthor, ValidationError>
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.
Sourcepub fn build_unchecked(self) -> EmbedAuthor
pub fn build_unchecked(self) -> EmbedAuthor
Returns the author without any check (D-180).
discord.js counterpart: EmbedAuthorOptions with validation off (disableValidators).