Skip to main content

validate_embeds

Function validate_embeds 

Source
pub fn validate_embeds(embeds: &[Embed]) -> Result<(), ValidationError>
Expand description

Checks the limits that apply to all embeds of one message together: at most 10 embeds and at most 6000 characters across them (see embed_length).

The embeds themselves are not checked again; build each with EmbedBuilder::build.

discord.js counterpart: none (@discordjs/builders checks each embed alone).

§Errors

ValidationError::TooMany for more than 10 embeds, then ValidationError::TooLong for more than 6000 characters, both with the field embeds.

§Examples

use djs_builders::{EmbedBuilder, ValidationError, validate_embeds};

let page = EmbedBuilder::new().description("x".repeat(4000)).build().unwrap();
assert!(validate_embeds(std::slice::from_ref(&page)).is_ok());
assert_eq!(
    validate_embeds(&[page.clone(), page]),
    Err(ValidationError::TooLong { field: "embeds".into(), max: 6000, actual: 8000 })
);