Struct EmbedBuilder
zaun_client::EmbedBuilder · Struct
pub struct EmbedBuilder { … }A rich embed, built with chained setters and sent with
MessageOptions::embed:
use zaun_client::{EmbedBuilder, MessageOptions, Picture};
let embed = EmbedBuilder::new() .title("Release 1.2") .url("https://example.com/releases/1.2") .description("What changed") .color(0x5865F2) .author("Release bot", None, Some(Picture::file("bot.png"))) .field("Fixes", "12", true) .field("Features", "3", true) .image(Picture::file("screenshot.png")) .footer("zaun", None);channel.send(MessageOptions::new().embed(embed))?;Methods
Section titled “Methods”pub fn new() -> SelfAn empty embed. One needs a title, a description, an author, a footer, a picture or a field to be sent.
pub fn title<impl Into<String>>(self, title: impl Into<String>) -> SelfThe title (1–256 characters).
description
Section titled “description”pub fn description<impl Into<String>>(self, description: impl Into<String>) -> SelfThe text (1–4 096 characters).
pub fn url<impl Into<String>>(self, url: impl Into<String>) -> SelfThe title’s link: https:// only. A reader opens it by choice; nothing loads it.
pub const fn color(self, color: u32) -> SelfThe colour of its edge, 0xRRGGBB.
timestamp
Section titled “timestamp”pub const fn timestamp(self, ms: u64) -> SelfA time it shows, ms since the Unix epoch.
author
Section titled “author”pub fn author<impl Into<String>>(self, name: impl Into<String>, url: Option<&str>, icon: Option<Picture>) -> SelfThe author line: a name (1–256 characters), a link (https://) and a small picture.
footer
Section titled “footer”pub fn footer<impl Into<String>>(self, text: impl Into<String>, icon: Option<Picture>) -> SelfThe footer line: a text (1–2 048 characters) and a small picture.
pub fn image<impl Into<Picture>>(self, picture: impl Into<Picture>) -> SelfThe large picture.
thumbnail
Section titled “thumbnail”pub fn thumbnail<impl Into<Picture>>(self, picture: impl Into<Picture>) -> SelfThe small picture in the corner.
pub fn field<impl Into<String>, impl Into<String>>(self, name: impl Into<String>, value: impl Into<String>, inline: bool) -> SelfAdds a field (name 1–256, value 1–1 024 characters; up to 25), shown beside the
neighbouring inline fields when inline.
to_embed
Section titled “to_embed”pub fn to_embed(&self) -> Option<Embed>The embed as the protocol has it, when no picture is left to upload.
pub fn check(&self) -> Result<()>Checks the embed against the protocol’s rules (lengths, links, 25 fields, not empty), as sending it would, without uploading anything.
Errors
Section titled “Errors”Error::Protocol naming the field and the rule.
Trait implementations
Section titled “Trait implementations”Clone, Debug, Default, Eq, From<Embed>, From<EmbedBuilder>, PartialEq, StructuralPartialEq