mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
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:
@@ -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;
|
||||
|
||||
1
packages/discord.js/typings/index.d.ts
vendored
1
packages/discord.js/typings/index.d.ts
vendored
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user