aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-03-12 16:45:21 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-03-12 16:45:21 -0500
commit9e8e5aee80159730ec1d631acb5c3a1e581f1d69 (patch)
tree81776b91bd4bc66ea8c046fd871df03bae432497 /src/commands
parentc4e6a313f8c34fdacc07232e12d9a44432aee472 (diff)
downloadtanzanite-9e8e5aee80159730ec1d631acb5c3a1e581f1d69.tar.gz
tanzanite-9e8e5aee80159730ec1d631acb5c3a1e581f1d69.tar.bz2
tanzanite-9e8e5aee80159730ec1d631acb5c3a1e581f1d69.zip
refactor: create and use util.overflowEmbed
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/moderation/massBan.ts37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/commands/moderation/massBan.ts b/src/commands/moderation/massBan.ts
index 529063d..faea94b 100644
--- a/src/commands/moderation/massBan.ts
+++ b/src/commands/moderation/massBan.ts
@@ -8,7 +8,7 @@ import {
type OptionalArgType
} from '#lib';
import assert from 'assert';
-import { ApplicationCommandOptionType, Collection, Embed, PermissionFlagsBits } from 'discord.js';
+import { ApplicationCommandOptionType, Collection, PermissionFlagsBits } from 'discord.js';
export default class MassBanCommand extends BushCommand {
public constructor() {
@@ -94,28 +94,21 @@ export default class MassBanCommand extends BushCommand {
const success = (res: BanResponse): boolean => [banResponse.SUCCESS, banResponse.DM_ERROR].includes(res as any);
- const embeds: Embed[] = [];
-
- for (let i = 0; i < res.length; i++) {
- 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.at(-1)! : embed();
-
- const joinedRows = currentEmbed.description ? `${currentEmbed.description}\n${row}` : row;
- if (joinedRows.length >= 2096) currentEmbed = embed();
- currentEmbed.setDescription(joinedRows);
- }
-
- assert(embeds.length >= 1);
+ const lines = res.map((_, i) => {
+ const id = ids[i];
+ const status = res[i];
+ const isSuccess = success(status);
+ const emoji = isSuccess ? util.emojis.success : util.emojis.error;
+ return `${emoji} ${id}${isSuccess ? '' : ` - ${status}`}`;
+ });
- embeds[0].setTitle(`Mass Ban Results`);
+ const embeds = util.overflowEmbed(
+ {
+ color: util.colors.DarkRed,
+ title: 'Mass Ban Results'
+ },
+ lines
+ );
return message.util.send({ embeds });
}