aboutsummaryrefslogtreecommitdiff
path: root/src/commands/utilities/highlight-clear.ts
blob: a5ff19eca8f4be48922822cdb39ed09617b4d455 (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
import { BushCommand, ConfirmationPrompt, emojis, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { highlightSubcommands } from './highlight-!.js';

export default class HighlightClearCommand extends BushCommand {
	public constructor() {
		super('highlight-clear', {
			aliases: [],
			category: 'utilities',
			description: highlightSubcommands.clear.description,
			usage: [],
			examples: [],
			clientPermissions: [],
			userPermissions: []
		});
	}

	public override async exec(message: CommandMessage | SlashMessage) {
		assert(message.inGuild());

		if (message.util.isSlashMessage(message)) await message.interaction.deferReply();

		const confirm = await ConfirmationPrompt.send(message, { content: `Are you sure you want to clear your highlight list?` });
		if (!confirm) return await message.util.reply(`${emojis.warn} You decided not to clear your highlight list.`);

		const success = await this.client.highlightManager.removeAllHighlights(message.guild.id, message.author.id);
		if (!success) return await message.util.reply(`${emojis.error} There was an error clearing your highlight list.`);

		return await message.util.reply(`${emojis.success} Successfully cleared your highlight list.`);
	}
}