aboutsummaryrefslogtreecommitdiff
path: root/src/commands/utilities/highlight-add.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-add.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-add.ts')
-rw-r--r--src/commands/utilities/highlight-add.ts61
1 files changed, 30 insertions, 31 deletions
diff --git a/src/commands/utilities/highlight-add.ts b/src/commands/utilities/highlight-add.ts
index 316a931..9c7506e 100644
--- a/src/commands/utilities/highlight-add.ts
+++ b/src/commands/utilities/highlight-add.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 HighlightAddCommand extends BushCommand {
@@ -9,6 +8,28 @@ export default class HighlightAddCommand extends BushCommand {
aliases: [],
category: 'utilities',
description: highlightSubcommands.add,
+ args: [
+ {
+ id: 'word',
+ description: highlightCommandArgs.add[0].description,
+ type: 'string',
+ match: 'rest',
+ prompt: highlightCommandArgs.add[0].description,
+ retry: highlightCommandArgs.add[0].retry,
+ optional: !highlightCommandArgs.add[0].required,
+ only: 'text',
+ slashType: false
+ },
+ {
+ id: 'regex',
+ description: highlightCommandArgs.add[1].description,
+ match: 'flag',
+ flag: '--regex',
+ prompt: highlightCommandArgs.add[1].description,
+ only: 'text',
+ slashType: false
+ }
+ ],
usage: [],
examples: [],
clientPermissions: [],
@@ -16,25 +37,6 @@ export default class HighlightAddCommand extends BushCommand {
});
}
- public override *args(): ArgumentGeneratorReturn {
- const word: ArgType<'string'> = yield {
- type: 'string',
- match: 'rest',
- prompt: {
- start: highlightCommandArgs.add[0].description,
- retry: highlightCommandArgs.add[0].retry,
- optional: !highlightCommandArgs.add[0].required
- }
- };
-
- const regex: boolean = yield {
- match: 'flag',
- flag: 'regex'
- };
-
- return { word, regex };
- }
-
public override async exec(
message: BushMessage | BushSlashMessage,
args: { word: ArgType<'string'>; regex: ArgType<'boolean'> }
@@ -58,22 +60,19 @@ export default class HighlightAddCommand extends BushCommand {
}
}
- const [highlight] = await Highlight.findOrCreate({
- where: {
- guild: message.guild.id,
- user: message.author.id
- }
+ const res = await client.highlightManager.addHighlight(message.guild.id, message.author.id, {
+ word: args.word,
+ regex: args.regex
});
- 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 already highlighted "${args.word}".`,
+ content: `${util.emojis.error} There was an error highlighting "${args.word}".`,
allowedMentions: AllowedMentions.none()
});
- highlight.words = util.addToArray(highlight.words, { word: args.word, regex: args.regex });
- await highlight.save();
-
return await message.util.reply({
content: `${util.emojis.success} Successfully added "${args.word}" to your highlight list.`,
allowedMentions: AllowedMentions.none()