diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-21 16:08:38 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-21 16:08:38 -0500 |
commit | 5116ccf230c933c290676d033a5639b3913ee03b (patch) | |
tree | 7ebd8bb012b22c016e8d38d79b551cf43155d4dd /src/listeners | |
parent | d3464427ea9b08b54a0444795bf4aedab55d3afc (diff) | |
download | tanzanite-5116ccf230c933c290676d033a5639b3913ee03b.tar.gz tanzanite-5116ccf230c933c290676d033a5639b3913ee03b.tar.bz2 tanzanite-5116ccf230c933c290676d033a5639b3913ee03b.zip |
perf: make massban actually work
Diffstat (limited to 'src/listeners')
-rw-r--r-- | src/listeners/member-custom/massBan.ts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/listeners/member-custom/massBan.ts b/src/listeners/member-custom/massBan.ts new file mode 100644 index 0000000..93089a3 --- /dev/null +++ b/src/listeners/member-custom/massBan.ts @@ -0,0 +1,38 @@ +import { BanResponse, banResponse, BushListener, type BushClientEvents } from '#lib'; +import { Embed } from 'discord.js'; + +export default class BushBanListener extends BushListener { + public constructor() { + super('massBan', { + emitter: 'client', + event: 'massBan', + category: 'member-custom' + }); + } + + public override async exec(...[moderator, guild, reason, results]: BushClientEvents['massBan']) { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + + const success = (res: BanResponse): boolean => [banResponse.SUCCESS, banResponse.DM_ERROR].includes(res as any); + + const logEmbed = new Embed() + .setColor(util.colors.DarkRed) + .setTimestamp() + .setTitle('Mass Ban') + .addFields( + { name: '**Moderator**', value: `${moderator} (${moderator.user.tag})` }, + { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } + ) + .setDescription( + results + .map( + (reason, user) => + `${success(reason) ? util.emojis.success : util.emojis.error} ${user}${success(reason) ? '' : ` - ${reason}`}` + ) + .join('\n') + ); + + return await logChannel.send({ embeds: [logEmbed] }); + } +} |