diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-03-12 15:32:57 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-03-12 15:32:57 -0500 |
commit | c4e6a313f8c34fdacc07232e12d9a44432aee472 (patch) | |
tree | 6898592033835da976c77bf9e4d2c5246fb85363 /src/commands/moderation | |
parent | 293fc2c5f86ea6aaa1ef19e784241b8a6656a166 (diff) | |
download | tanzanite-c4e6a313f8c34fdacc07232e12d9a44432aee472.tar.gz tanzanite-c4e6a313f8c34fdacc07232e12d9a44432aee472.tar.bz2 tanzanite-c4e6a313f8c34fdacc07232e12d9a44432aee472.zip |
fix(MassBanCommand): remove undefined when description embed description is undefined
Diffstat (limited to 'src/commands/moderation')
-rw-r--r-- | src/commands/moderation/massBan.ts | 12 |
1 files changed, 8 insertions, 4 deletions
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); |