From c4e6a313f8c34fdacc07232e12d9a44432aee472 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sat, 12 Mar 2022 15:32:57 -0500 Subject: fix(MassBanCommand): remove undefined when description embed description is undefined --- src/commands/moderation/massBan.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/commands') diff --git a/src/commands/moderation/massBan.ts b/src/commands/moderation/massBan.ts index 18c3b50..529063d 100644 --- a/src/commands/moderation/massBan.ts +++ b/src/commands/moderation/massBan.ts @@ -97,16 +97,20 @@ export default class MassBanCommand extends BushCommand { const embeds: Embed[] = []; for (let i = 0; i < res.length; i++) { - const embed = () => embeds[embeds.push(new Embed().setColor(util.colors.DarkRed)) - 1]; + const embed = () => { + embeds.push(new Embed().setColor(util.colors.DarkRed)); + return embeds.at(-1)!; + }; const row = `${success(res[i]) ? util.emojis.success : util.emojis.error} ${ids[i]}${ success(res[i]) ? '' : ` - ${res[i]}` }`; - let currentEmbed = embeds.length ? embeds[embeds.length - 1] : embed(); + let currentEmbed = embeds.length ? embeds.at(-1)! : embed(); - if (`${currentEmbed.description}\n${row}`.length >= 2096) currentEmbed = embed(); - currentEmbed.setDescription(`${currentEmbed.description}\n${row}`); + const joinedRows = currentEmbed.description ? `${currentEmbed.description}\n${row}` : row; + if (joinedRows.length >= 2096) currentEmbed = embed(); + currentEmbed.setDescription(joinedRows); } assert(embeds.length >= 1); -- cgit