Skip to main content

embed_length

Function embed_length 

Source
pub fn embed_length(embed: &Embed) -> usize
Expand description

Returns the number of characters of embed that count toward Discord’s 6000-character limit: its title, description, field names and values, footer text and author name, each measured in Unicode code points after trimming (D-183).

discord.js counterpart: embedLength (which counts UTF-16 code units, untrimmed).

§Examples

use djs_builders::{EmbedBuilder, embed_length};

let embed = EmbedBuilder::new()
    .title("  Hi  ")        // 2: surrounding whitespace is not counted
    .description("🔥🔥🔥") // 3: one per code point
    .field("a", "bc")       // 3
    .build_unchecked();
assert_eq!(embed_length(&embed), 8);