mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01:00
fix(MessageEmbed): include author.name in length getter (#5167)
* fix(MessageEmbed): include `author.name` in length getter * Update src/structures/MessageEmbed.js Co-authored-by: Papaia <43409674+papaia@users.noreply.github.com> * style: oxford comma Co-authored-by: Papaia <43409674+papaia@users.noreply.github.com> * refactor: es2020 syntax Co-authored-by: Papaia <43409674+papaia@users.noreply.github.com>
This commit is contained in:
@@ -231,18 +231,19 @@ class MessageEmbed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The accumulated length for the embed title, description, fields and footer text
|
* The accumulated length for the embed title, description, fields, footer text, and author name
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
get length() {
|
get length() {
|
||||||
return (
|
return (
|
||||||
(this.title ? this.title.length : 0) +
|
(this.title?.length ?? 0) +
|
||||||
(this.description ? this.description.length : 0) +
|
(this.description?.length ?? 0) +
|
||||||
(this.fields.length >= 1
|
(this.fields.length >= 1
|
||||||
? this.fields.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0)
|
? this.fields.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0)
|
||||||
: 0) +
|
: 0) +
|
||||||
(this.footer ? this.footer.text.length : 0)
|
(this.footer?.text.length ?? 0) +
|
||||||
|
(this.author?.name.length ?? 0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user