aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
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 });
}