# `Noizu.Discord.Embeds`
[🔗](https://github.com/noizu-labs-sdks/elixir-discord/blob/v0.1.0/lib/noizu/discord/embeds.ex#L1)

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.

# `embed`

```elixir
@type embed() :: map()
```

# `author`

```elixir
@spec author(embed(), String.t(), keyword()) :: embed()
```

Sets the author. Opts: `:url`, `:icon_url`.

# `color`

```elixir
@spec color(embed(), integer() | String.t()) :: embed()
```

Sets the sidebar color from an integer (`0x2ECC71`) or hex string (`"#2ecc71"`).

# `description`

```elixir
@spec description(embed(), String.t()) :: embed()
```

Sets the description (markdown).

# `field`

```elixir
@spec field(embed(), String.t(), String.t(), boolean()) :: embed()
```

Appends a field.

# `footer`

```elixir
@spec footer(embed(), String.t() | map()) :: embed()
```

Sets the footer text (or a full footer map, e.g. with `icon_url`).

# `limits`

```elixir
@spec limits() :: map()
```

Discord embed limits.

# `new`

```elixir
@spec new(map() | keyword()) :: embed()
```

New embed, optionally seeded from a map or keyword list (`type: "rich"` default).

# `timestamp`

```elixir
@spec timestamp(embed(), DateTime.t() | NaiveDateTime.t() | String.t()) :: embed()
```

Sets the ISO8601 timestamp (`DateTime`, `NaiveDateTime` as UTC, or string).

# `title`

```elixir
@spec title(embed(), String.t()) :: embed()
```

Sets the title.

# `total_length`

```elixir
@spec total_length([embed()] | embed()) :: non_neg_integer()
```

Total counted characters of a list of embeds (title, description, fields, footer, author).

# `url`

```elixir
@spec url(embed(), String.t()) :: embed()
```

Sets the title link URL.

# `validate`

```elixir
@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}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
