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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
import { AllowedMentions, BushCommand, Highlight, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
import { ArgumentGeneratorReturn } from 'discord-akairo';
import { highlightCommandArgs, highlightSubcommands } from './highlight-!';
export default class HighlightRemoveCommand extends BushCommand {
public constructor() {
super('highlight-remove', {
aliases: [],
category: 'utilities',
description: highlightSubcommands.remove,
usage: [],
examples: [],
clientPermissions: [],
userPermissions: []
});
}
public override *args(): ArgumentGeneratorReturn {
const word: ArgType<'string'> = yield {
type: 'string',
match: 'rest',
prompt: {
start: highlightCommandArgs.remove[0].description,
retry: highlightCommandArgs.remove[0].retry,
optional: !highlightCommandArgs.remove[0].required
}
};
return { word };
}
public override async exec(message: BushMessage | BushSlashMessage, args: { word: ArgType<'string'> }) {
assert(message.inGuild());
const [highlight] = await Highlight.findOrCreate({
where: {
guild: message.guild.id,
user: message.author.id
}
});
if (!highlight.words.some((w) => w.word === args.word))
return await message.util.reply({
content: `${util.emojis.error} You have not highlighted "${args.word}".`,
allowedMentions: AllowedMentions.none()
});
highlight.words = util.removeFromArray(highlight.words, highlight.words.find((w) => w.word === args.word)!);
await highlight.save();
return await message.util.reply({
content: `${util.emojis.success} Successfully removed "${args.word}" from your highlight list.`,
allowedMentions: AllowedMentions.none()
});
}
}
|