Skip to content

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))?;
pub fn new() -> Self

An 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>) -> Self

The title (1–256 characters).

pub fn description<impl Into<String>>(self, description: impl Into<String>) -> Self

The text (1–4 096 characters).

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

The title’s link: https:// only. A reader opens it by choice; nothing loads it.

pub const fn color(self, color: u32) -> Self

The colour of its edge, 0xRRGGBB.

pub const fn timestamp(self, ms: u64) -> Self

A time it shows, ms since the Unix epoch.

pub fn author<impl Into<String>>(self, name: impl Into<String>, url: Option<&str>, icon: Option<Picture>) -> Self

The author line: a name (1–256 characters), a link (https://) and a small picture.

pub fn footer<impl Into<String>>(self, text: impl Into<String>, icon: Option<Picture>) -> Self

The footer line: a text (1–2 048 characters) and a small picture.

pub fn image<impl Into<Picture>>(self, picture: impl Into<Picture>) -> Self

The large picture.

pub fn thumbnail<impl Into<Picture>>(self, picture: impl Into<Picture>) -> Self

The 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) -> Self

Adds a field (name 1–256, value 1–1 024 characters; up to 25), shown beside the neighbouring inline fields when inline.

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.

Error::Protocol naming the field and the rule.

Clone, Debug, Default, Eq, From<Embed>, From<EmbedBuilder>, PartialEq, StructuralPartialEq

Full rustdoc page