aboutsummaryrefslogtreecommitdiff
path: root/src/commands/utilities/highlight-clear.ts
blob: aded467b6818b25545a24475fcab177b49483ea0 (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
33
34
35
36
37
38
39
import { AllowedMentions, BushCommand, ConfirmationPrompt, Highlight, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
import { highlightSubcommands } from './highlight-!';

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

	public override async exec(message: BushMessage | BushSlashMessage) {
		assert(message.inGuild());

		const [highlight] = await Highlight.findOrCreate({
			where: {
				guild: message.guild.id,
				user: message.author.id
			}
		});

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

		highlight.words = [];
		await highlight.save();

		return await message.util.reply({
			content: `${util.emojis.success} Successfully cleared your highlight list.`,
			allowedMentions: AllowedMentions.none()
		});
	}
}