From e37160f4e3d647e8e33b5b03d5f9e6c98b065499 Mon Sep 17 00:00:00 2001 From: Bread <60681223+vBread@users.noreply.github.com> Date: Thu, 31 Dec 2020 18:11:52 -0500 Subject: [PATCH] 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> --- src/structures/MessageEmbed.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/structures/MessageEmbed.js b/src/structures/MessageEmbed.js index ef007a551cec..8d9dce92b0aa 100644 --- a/src/structures/MessageEmbed.js +++ b/src/structures/MessageEmbed.js @@ -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) ); }