@notoiro/djs-button-pages
Version:
A simple yet powerful module for implementing customizable embed pages with buttons in Discord chat. Works only with Discord.js.
20 lines (19 loc) • 650 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Gets embed length.
* Includes author name, footer, fields, description and title.
* @param {APIEmbed} embed Embed which length should be counted.
* @returns {number} Embed length.
*/
function getEmbedLength(embed) {
return (embed.author?.name.length ?? 0) +
(embed.footer?.text?.length ?? 0) +
(embed.fields ?
embed.fields.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0)
: 0) +
(embed.description?.length ?? 0) +
(embed.title?.length ?? 0);
}
;
exports.default = getEmbedLength;