Skip to content

Commit

Permalink
fix(MessageEmbed): include author.name in length getter (#5167)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
xiBread and papaia committed Dec 31, 2020
1 parent 57b3ba4 commit e37160f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/structures/MessageEmbed.js
Expand Up @@ -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)
);
}

Expand Down

0 comments on commit e37160f

Please sign in to comment.