Pipeable embed builders plus limit validation.
embed =
Noizu.Discord.Embeds.new()
|> Noizu.Discord.Embeds.title("Deploy finished")
|> Noizu.Discord.Embeds.description("All green.")
|> Noizu.Discord.Embeds.color("#2ecc71")
|> Noizu.Discord.Embeds.field("Env", "prod", true)
{:ok, [embed]} = Noizu.Discord.Embeds.validate(embed)Embeds are plain maps with atom keys, ready to drop into embeds: of a message.
Limits (limits/0)
title 256 · description 4096 · 25 fields · field name 256 · field value 1024 · footer text 2048 · author name 256 · 6000 characters total across all embeds of a message · 10 embeds per message.
Summary
Functions
Sets the author. Opts: :url, :icon_url.
Sets the sidebar color from an integer (0x2ECC71) or hex string ("#2ecc71").
Sets the description (markdown).
Appends a field.
Sets the footer text (or a full footer map, e.g. with icon_url).
Discord embed limits.
New embed, optionally seeded from a map or keyword list (type: "rich" default).
Sets the ISO8601 timestamp (DateTime, NaiveDateTime as UTC, or string).
Sets the title.
Total counted characters of a list of embeds (title, description, fields, footer, author).
Sets the title link URL.
Validates one embed or a list of embeds (one message) against Discord's limits.
Types
@type embed() :: map()
Functions
Sets the author. Opts: :url, :icon_url.
Sets the sidebar color from an integer (0x2ECC71) or hex string ("#2ecc71").
Sets the description (markdown).
Appends a field.
@spec limits() :: map()
Discord embed limits.
New embed, optionally seeded from a map or keyword list (type: "rich" default).
@spec timestamp(embed(), DateTime.t() | NaiveDateTime.t() | String.t()) :: embed()
Sets the ISO8601 timestamp (DateTime, NaiveDateTime as UTC, or string).
Sets the title.
@spec total_length([embed()] | embed()) :: non_neg_integer()
Total counted characters of a list of embeds (title, description, fields, footer, author).
Sets the title link URL.
@spec validate(embed() | [embed()], keyword()) :: {:ok, [embed()]} | {:error, Noizu.Discord.Error.t()}
Validates one embed or a list of embeds (one message) against Discord's limits.
Returns {:ok, embeds_list} or {:error, %Error{tag: :validation, reason: r}} with
r in :too_many_embeds, :title_too_long, :description_too_long,
:too_many_fields, :field_name_too_long, :field_value_too_long,
:footer_too_long, :author_name_too_long, :embed_too_long.
Opts: on_overflow: :truncate instead truncates text with a "…" marker, drops
fields past 25 and embeds past 10, then shrinks descriptions/fields until the
6000-character total fits — always returning {:ok, embeds}.