aboutsummaryrefslogtreecommitdiff
path: root/src/commands/tickets/ticket-!.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-08-05 23:24:51 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-08-05 23:24:51 -0400
commit1feb515882cfbbf33dc98d75a54898c1735cf5cb (patch)
tree20386e9d6ca6b5cb978283d672528c03647ec32f /src/commands/tickets/ticket-!.ts
parente68a0193b9f5888455f631d72c8783fc50e35faf (diff)
parent060349fcabe9e073eca9f6fd334e3355a9756096 (diff)
downloadtanzanite-1feb515882cfbbf33dc98d75a54898c1735cf5cb.tar.gz
tanzanite-1feb515882cfbbf33dc98d75a54898c1735cf5cb.tar.bz2
tanzanite-1feb515882cfbbf33dc98d75a54898c1735cf5cb.zip
Merge branch 'wip'
Diffstat (limited to 'src/commands/tickets/ticket-!.ts')
-rw-r--r--src/commands/tickets/ticket-!.ts65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/commands/tickets/ticket-!.ts b/src/commands/tickets/ticket-!.ts
new file mode 100644
index 0000000..6ec4093
--- /dev/null
+++ b/src/commands/tickets/ticket-!.ts
@@ -0,0 +1,65 @@
+import { BushCommand, clientSendAndPermCheck, deepWriteable, type SlashMessage } from '#lib';
+import { Flag, type ArgumentGeneratorReturn, type SlashOption } from 'discord-akairo';
+import { ApplicationCommandOptionType } from 'discord.js';
+
+export const ticketSubcommands = deepWriteable({
+ create: {
+ description: 'Create a ticket.',
+ type: ApplicationCommandOptionType.Subcommand,
+ options: [
+ {
+ name: 'word',
+ description: 'What word do you want to highlight?',
+ retry: '{error} Enter a valid word.',
+ type: ApplicationCommandOptionType.String,
+ required: true
+ }
+ ]
+ }
+} as const);
+
+export default class TicketCommand extends BushCommand {
+ public constructor() {
+ super('ticket', {
+ aliases: ['ticket'],
+ category: 'ticket',
+ description: 'Manage tickets.',
+ usage: ['ticket create <reason>'],
+ examples: ['ticket creates very cool ticket'],
+ slashOptions: Object.entries(ticketSubcommands).map(
+ ([subcommand, options]) => ({ name: subcommand, ...options } as SlashOption)
+ ),
+ slash: false,
+ channel: 'guild',
+ clientPermissions: (m) => clientSendAndPermCheck(m),
+ userPermissions: [],
+ ownerOnly: true,
+ hidden: true
+ });
+ }
+
+ public override *args(): ArgumentGeneratorReturn {
+ const subcommand: keyof typeof ticketSubcommands = yield {
+ id: 'subcommand',
+ type: Object.keys(ticketSubcommands),
+ prompt: {
+ start: 'What sub command would you like to use?',
+ retry: `{error} Valid subcommands are: ${Object.keys(ticketSubcommands)
+ .map((s) => `\`${s}\``)
+ .join()}.`
+ }
+ };
+
+ return Flag.continue(`ticket-${subcommand}`);
+ }
+
+ public override async exec() {
+ throw new Error('This command is not meant to be executed directly.');
+ }
+
+ public override async execSlash(message: SlashMessage, args: { subcommand: string; subcommandGroup?: string }) {
+ // manual `Flag.continue`
+ const subcommand = this.handler.modules.get(`ticket-${args.subcommandGroup ?? args.subcommand}`)!;
+ return subcommand.exec(message, args);
+ }
+}