aboutsummaryrefslogtreecommitdiff
path: root/src/listeners/guild-custom/unlockdown.ts
blob: 6b6e16edfd33378b2c336e6c82a562653730a487 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { BotListener, colors, Emitter, emojis, TanzaniteEvent, type BotClientEvents } from '#lib';
import { EmbedBuilder } from 'discord.js';

export default class UnlockdownListener extends BotListener {
	public constructor() {
		super(TanzaniteEvent.Unlockdown, {
			emitter: Emitter.Client,
			event: TanzaniteEvent.Unlockdown
		});
	}

	public async exec(...[moderator, reason, channelsSuccessMap, _all]: BotClientEvents[TanzaniteEvent.Unlockdown]) {
		const logChannel = await moderator.guild.getLogChannel('moderation');
		if (!logChannel) return;

		const logEmbed = new EmbedBuilder()
			.setColor(colors.Blurple)
			.setTimestamp()
			.addFields(
				{ name: '**Action**', value: `${'Unlockdown'}` },
				{ name: '**Moderator**', value: `${moderator} (${moderator.user.tag})` },
				{ name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` },
				{
					name: `**Channel${channelsSuccessMap.size > 1 ? 's' : ''}**`,
					value: channelsSuccessMap
						.map((success, channel) => `<#${channel}> ${success ? emojis.success : emojis.error}`)
						.join('\n')
				}
			);
		return await logChannel.send({ embeds: [logEmbed] });
	}
}