aboutsummaryrefslogtreecommitdiff
path: root/src/commands/utilities/highlight-remove.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-07 23:55:54 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-07 23:55:54 -0500
commit2bcf6828b67a6eb3c2bbff3892ce5ca53d00e713 (patch)
tree77d706d1d33c92eab7823c415629d14c0b887960 /src/commands/utilities/highlight-remove.ts
parentc3ae31a7539ecb5455df811a2e1d5603beb5c9ae (diff)
downloadtanzanite-2bcf6828b67a6eb3c2bbff3892ce5ca53d00e713.tar.gz
tanzanite-2bcf6828b67a6eb3c2bbff3892ce5ca53d00e713.tar.bz2
tanzanite-2bcf6828b67a6eb3c2bbff3892ce5ca53d00e713.zip
started working on highlight command
Diffstat (limited to 'src/commands/utilities/highlight-remove.ts')
-rw-r--r--src/commands/utilities/highlight-remove.ts57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/commands/utilities/highlight-remove.ts b/src/commands/utilities/highlight-remove.ts
new file mode 100644
index 0000000..0432a16
--- /dev/null
+++ b/src/commands/utilities/highlight-remove.ts
@@ -0,0 +1,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()
+ });
+ }
+}