aboutsummaryrefslogtreecommitdiff
path: root/src/commands/utilities/highlight-remove.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-23 21:38:40 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-23 21:38:40 -0500
commit084a815f3799764d2dd697e8c693c7f80e0c7ab7 (patch)
tree7c62c41824d8ab25a67fe35016b6514744d33402 /src/commands/utilities/highlight-remove.ts
parentd64563e89034b8e016d1b0a24e2b44280900b14c (diff)
downloadtanzanite-084a815f3799764d2dd697e8c693c7f80e0c7ab7.tar.gz
tanzanite-084a815f3799764d2dd697e8c693c7f80e0c7ab7.tar.bz2
tanzanite-084a815f3799764d2dd697e8c693c7f80e0c7ab7.zip
feat(hl): make functional, no cool downs yet, restrcited to su
Diffstat (limited to 'src/commands/utilities/highlight-remove.ts')
-rw-r--r--src/commands/utilities/highlight-remove.ts46
1 files changed, 19 insertions, 27 deletions
diff --git a/src/commands/utilities/highlight-remove.ts b/src/commands/utilities/highlight-remove.ts
index 1f7c4c0..7e8c416 100644
--- a/src/commands/utilities/highlight-remove.ts
+++ b/src/commands/utilities/highlight-remove.ts
@@ -1,6 +1,5 @@
-import { AllowedMentions, BushCommand, Highlight, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
-import { ArgumentGeneratorReturn } from 'discord-akairo';
import { highlightCommandArgs, highlightSubcommands } from './highlight-!.js';
export default class HighlightRemoveCommand extends BushCommand {
@@ -9,6 +8,19 @@ export default class HighlightRemoveCommand extends BushCommand {
aliases: [],
category: 'utilities',
description: highlightSubcommands.remove,
+ args: [
+ {
+ id: 'word',
+ description: highlightCommandArgs.remove[0].description,
+ type: 'string',
+ match: 'rest',
+ prompt: highlightCommandArgs.remove[0].description,
+ retry: highlightCommandArgs.remove[0].retry,
+ optional: !highlightCommandArgs.remove[0].required,
+ only: 'text',
+ slashType: false
+ }
+ ],
usage: [],
examples: [],
clientPermissions: [],
@@ -16,39 +28,19 @@ export default class HighlightRemoveCommand extends BushCommand {
});
}
- 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
- }
- });
+ const res = await client.highlightManager.removeHighlight(message.guild.id, message.author.id, args.word);
- if (!highlight.words.some((w) => w.word === args.word))
+ if (typeof res === 'string')
+ return await message.util.reply({ content: `${util.emojis.error} ${res}`, allowedMentions: AllowedMentions.none() });
+ else if (!res)
return await message.util.reply({
- content: `${util.emojis.error} You have not highlighted "${args.word}".`,
+ content: `${util.emojis.error} There was an error unhighlighting "${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()