mirror of
https://github.com/danbulant/discord.js
synced 2026-05-31 05:11:51 +00:00
feat(RichEmbed): add length getter (#3057)
This commit is contained in:
parent
a2a0c05102
commit
890b1be714
2 changed files with 16 additions and 0 deletions
|
|
@ -235,6 +235,21 @@ class RichEmbed {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The accumulated length for the embed title, description, fields, author 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) +
|
||||
(this.author ? this.author.name.length : 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the embed object to be processed.
|
||||
* @returns {Object} The raw data of this embed
|
||||
|
|
|
|||
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
|
|
@ -1015,6 +1015,7 @@ declare module 'discord.js' {
|
|||
public files?: Array<Attachment | string | FileOptions>;
|
||||
public footer?: { text?: string; icon_url?: string; };
|
||||
public image?: { url: string; proxy_url?: string; height?: number; width?: number; };
|
||||
public readonly length: number;
|
||||
public thumbnail?: { url: string; height?: number; width?: number; };
|
||||
public timestamp?: Date;
|
||||
public title?: string;
|
||||
|
|
|
|||
Loading…
Reference in a new issue