diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-23 21:12:49 +0000 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-23 21:12:49 +0000 |
commit | 00d447d2e2e4d04079a1f4ac004694d93ae505b7 (patch) | |
tree | 1cbb2152ea13136a20dae5d79de819c21efb9b51 | |
parent | 3f97bce09b7f0799fe9b40efa6ca85a07b009ad5 (diff) | |
download | tanzanite-00d447d2e2e4d04079a1f4ac004694d93ae505b7.tar.gz tanzanite-00d447d2e2e4d04079a1f4ac004694d93ae505b7.tar.bz2 tanzanite-00d447d2e2e4d04079a1f4ac004694d93ae505b7.zip |
fix(MassBanCommand): handle long embeds
-rw-r--r-- | src/commands/moderation/massBan.ts | 28 |
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 }); } } |