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:
Bread
2020-12-31 18:11:52 -05:00
committed by GitHub
parent 57b3ba425e
commit e37160f4e3

View File

@@ -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}
* @readonly
*/
get length() {
return (
(this.title ? this.title.length : 0) +
(this.description ? this.description.length : 0) +
(this.title?.length ?? 0) +
(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.footer?.text.length ?? 0) +
(this.author?.name.length ?? 0)
);
}