aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-23 21:12:49 +0000
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-23 21:12:49 +0000
commit00d447d2e2e4d04079a1f4ac004694d93ae505b7 (patch)
tree1cbb2152ea13136a20dae5d79de819c21efb9b51 /src/commands
parent3f97bce09b7f0799fe9b40efa6ca85a07b009ad5 (diff)
downloadtanzanite-00d447d2e2e4d04079a1f4ac004694d93ae505b7.tar.gz
tanzanite-00d447d2e2e4d04079a1f4ac004694d93ae505b7.tar.bz2
tanzanite-00d447d2e2e4d04079a1f4ac004694d93ae505b7.zip
fix(MassBanCommand): handle long embeds
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/moderation/massBan.ts28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/commands/moderation/massBan.ts b/src/commands/moderation/massBan.ts
index 499bcd4..3a613cd 100644
--- a/src/commands/moderation/massBan.ts
+++ b/src/commands/moderation/massBan.ts
@@ -94,15 +94,23 @@ export default class MassBanCommand extends BushCommand {
const success = (res: BanResponse): boolean => [banResponse.SUCCESS, banResponse.DM_ERROR].includes(res as any);
- const embed = new Embed()
- .setTitle(`Mass Ban Results`)
- .setDescription(
- res
- .map((r, i) => `${success(r) ? util.emojis.success : util.emojis.error} ${ids[i]}${success(r) ? '' : ` - ${r}`}`)
- .join('\n')
- )
- .setColor(util.colors.DarkRed);
-
- return message.util.send({ embeds: [embed] });
+ const embeds: Embed[] = [];
+
+ for (let i = 0; i < res.length; i++) {
+ const embed = ()=> embeds[embeds.push(new Embed().setColor(util.colors.DarkRed))-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()
+
+ if (`${currentEmbed.description}\n${row}`.length >= 2048) currentEmbed = embed()
+ currentEmbed.setDescription(`${currentEmbed.description}\n${row}`)
+ }
+
+ assert(embeds.length >=1)
+
+ embeds[0].setTitle(`Mass Ban Results`)
+
+ return message.util.send({ embeds });
}
}