feat(EmbedBuilder): add .length (#8682)

* feat(Embed): add `.length`

Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>

* Move to mainlib

Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>

* types: add typings

---------

Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
RedGuy12
2023-07-07 16:53:19 -05:00
committed by GitHub
parent dc73c938ff
commit 53c17e00c0
2 changed files with 10 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
'use strict';
const { EmbedBuilder: BuildersEmbed } = require('@discordjs/builders');
const { EmbedBuilder: BuildersEmbed, embedLength } = require('@discordjs/builders');
const { isJSONEncodable } = require('@discordjs/util');
const { toSnakeCase } = require('../util/Transformers');
const { resolveColor } = require('../util/Util');
@@ -31,6 +31,14 @@ class EmbedBuilder extends BuildersEmbed {
static from(other) {
return new this(isJSONEncodable(other) ? other.toJSON() : other);
}
/**
* The accumulated length for the embed title, description, fields, footer text, and author name.
* @type {number}
*/
get length() {
return embedLength(this.data);
}
}
module.exports = EmbedBuilder;

View File

@@ -857,6 +857,7 @@ export class EmbedBuilder extends BuildersEmbed {
public constructor(data?: EmbedData | APIEmbed);
public override setColor(color: ColorResolvable | null): this;
public static from(other: JSONEncodable<APIEmbed> | APIEmbed): EmbedBuilder;
public get length(): number;
}
export class Embed {