refactor!: move embedLength function to util package (#11327)

BREAKING CHANGE: Builders no longer exports a `embedLength` function. Import it from `@discordjs/util` instead.

Co-authored-by: Danial Raza <danialrazafb@gmail.com>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
Almeida
2025-12-09 18:40:34 +00:00
committed by GitHub
parent 4db1092f8f
commit f60d3d65fe
7 changed files with 27 additions and 6 deletions

View File

@@ -89,7 +89,6 @@ export * from './messages/Attachment.js';
export * from './messages/Message.js';
export * from './messages/MessageReference.js';
export * from './util/componentUtil.js';
export * from './util/normalizeArray.js';
export * from './util/resolveBuilder.js';
export { disableValidators, enableValidators, isValidationEnabled } from './util/validation.js';

View File

@@ -1,5 +1,5 @@
import { embedLength } from '@discordjs/util';
import { z } from 'zod';
import { embedLength } from '../../util/componentUtil.js';
const namePredicate = z.string().max(256);

View File

@@ -1,16 +0,0 @@
import type { APIEmbed } from 'discord-api-types/v10';
/**
* Calculates the length of the embed.
*
* @param data - The embed data to check
*/
export function embedLength(data: APIEmbed) {
return (
(data.title?.length ?? 0) +
(data.description?.length ?? 0) +
(data.fields?.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0) ?? 0) +
(data.footer?.text.length ?? 0) +
(data.author?.name.length ?? 0)
);
}