mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
feat: MessageEmbed#length (#3003)
* add MessageEmbed#length * update typings (+MessageEmbed#length) * eslint: L181 (max line length), L183 (missing semi) * eslint: L181 (trailing space)
This commit is contained in:
@@ -169,6 +169,20 @@ class MessageEmbed {
|
|||||||
return this.color ? `#${this.color.toString(16).padStart(6, '0')}` : null;
|
return this.color ? `#${this.color.toString(16).padStart(6, '0')}` : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The accumulated length for the embed title, description, fields and footer text
|
||||||
|
* @type {number}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get length() {
|
||||||
|
return (
|
||||||
|
(this.title ? this.title.length : 0) +
|
||||||
|
(this.description ? this.description.length : 0) +
|
||||||
|
(this.fields.length >= 1 ? this.fields.reduce((prev, curr) =>
|
||||||
|
prev + curr.name.length + curr.value.length, 0) : 0) +
|
||||||
|
(this.footer ? this.footer.text.length : 0));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a field to the embed (max 25).
|
* Adds a field to the embed (max 25).
|
||||||
* @param {StringResolvable} name The name of the field
|
* @param {StringResolvable} name The name of the field
|
||||||
|
|||||||
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
@@ -729,6 +729,7 @@ declare module 'discord.js' {
|
|||||||
public footer: { text?: string; iconURL?: string; proxyIconURL?: string };
|
public footer: { text?: string; iconURL?: string; proxyIconURL?: string };
|
||||||
public readonly hexColor: string;
|
public readonly hexColor: string;
|
||||||
public image: { url: string; proxyURL?: string; height?: number; width?: number; };
|
public image: { url: string; proxyURL?: string; height?: number; width?: number; };
|
||||||
|
public readonly length: number;
|
||||||
public provider: { name: string; url: string; };
|
public provider: { name: string; url: string; };
|
||||||
public thumbnail: { url: string; proxyURL?: string; height?: number; width?: number; };
|
public thumbnail: { url: string; proxyURL?: string; height?: number; width?: number; };
|
||||||
public timestamp: number;
|
public timestamp: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user