aboutsummaryrefslogtreecommitdiff
path: root/src/commands/utilities/highlight-matches.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-matches.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-matches.ts')
-rw-r--r--src/commands/utilities/highlight-matches.ts56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/commands/utilities/highlight-matches.ts b/src/commands/utilities/highlight-matches.ts
index e69de29..aa8308c 100644
--- a/src/commands/utilities/highlight-matches.ts
+++ b/src/commands/utilities/highlight-matches.ts
@@ -0,0 +1,56 @@
+import { BushCommand, ButtonPaginator, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import assert from 'assert';
+import { ArgumentGeneratorReturn } from 'discord-akairo';
+import { APIEmbed } from 'discord-api-types/v9';
+import { highlightCommandArgs, highlightSubcommands } from './highlight-!.js';
+
+export default class HighlightMatchesCommand extends BushCommand {
+ public constructor() {
+ super('highlight-matches', {
+ aliases: [],
+ category: 'utilities',
+ description: highlightSubcommands.matches,
+ usage: [],
+ examples: [],
+ clientPermissions: [],
+ userPermissions: []
+ });
+ }
+
+ public override *args(): ArgumentGeneratorReturn {
+ const phrase: ArgType<'string'> = yield {
+ type: 'string',
+ match: 'rest',
+ prompt: {
+ start: highlightCommandArgs.matches[0].description,
+ retry: highlightCommandArgs.matches[0].retry,
+ optional: !highlightCommandArgs.matches[0].required
+ }
+ };
+
+ return { phrase };
+ }
+
+ public override async exec(message: BushMessage | BushSlashMessage, args: { phrase: ArgType<'string'> }) {
+ assert(message.inGuild());
+
+ const res = await client.highlightManager.checkPhrase(message.guild.id, message.author.id, args.phrase);
+
+ if (!res.size) return await message.util.reply(`${util.emojis.error} You are not highlighting any words`);
+
+ const lines = res.map(
+ (passed, hl) => `${passed ? util.emojis.check : util.emojis.cross} ${hl.regex ? `/${hl.word}/gi` : hl.word}`
+ );
+ const chunked = util.chunk(lines, 10);
+
+ const pages = chunked.map(
+ (chunk): APIEmbed => ({
+ title: `Matches`,
+ description: chunk.join('\n'),
+ color: util.colors.default
+ })
+ );
+
+ return pages.length > 1 ? await ButtonPaginator.send(message, pages) : message.util.send({ embeds: pages });
+ }
+}