mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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).
|
||||
* @param {StringResolvable} name The name of the field
|
||||
|
||||
Reference in New Issue
Block a user