From 60e7cc2369d9b2b9ad6cf864569197123305974a Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 14 Jun 2022 14:47:07 -0500 Subject: [PATCH] feat: revamp module types to support event plugins --- src/handler/structures/module.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index b28a973..22b1b73 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -5,8 +5,10 @@ import type { ApplicationCommandNonOptionsData, ApplicationCommandNumericOptionData, ApplicationCommandOptionData, + ApplicationCommandOptionType, ApplicationCommandSubCommandData, ApplicationCommandSubGroupData, + AutocompleteInteraction, Awaitable, BaseApplicationCommandOptionsData, ButtonInteraction, @@ -19,8 +21,7 @@ import type { Args, Override, SlashOptions } from '../../types/handler'; import type { CommandPlugin, EventPlugin } from '../plugins/plugin'; import type Context from './context'; import { CommandType, PluginType } from './enums'; -import type { AutocompleteInteraction } from 'discord.js'; -import type { ApplicationCommandOptionType } from 'discord.js'; +import type { DiscordEventCommand, ExternalEventCommand, SernEventCommand } from './events'; export interface BaseModule { type: CommandType | PluginType; @@ -127,8 +128,8 @@ export type AutocompleteCommand = Override< execute: (ctx: AutocompleteInteraction) => Awaitable; } >; - -export type Module = +export type EventModule = DiscordEventCommand | SernEventCommand | ExternalEventCommand; +export type CommandModule = | TextCommand | SlashCommand | BothCommand @@ -139,6 +140,8 @@ export type Module = | ModalSubmitCommand | AutocompleteCommand; +export type Module = CommandModule | EventModule; + //https://stackoverflow.com/questions/64092736/alternative-to-switch-statement-for-typescript-discriminated-union // Explicit Module Definitions for mapping export type ModuleDefs = { @@ -151,6 +154,9 @@ export type ModuleDefs = { [CommandType.MenuSelect]: SelectMenuCommand; [CommandType.Modal]: ModalSubmitCommand; [CommandType.Autocomplete]: AutocompleteCommand; + [CommandType.Sern]: SernEventCommand; + [CommandType.Discord]: DiscordEventCommand; + [CommandType.External]: ExternalEventCommand; }; //TODO: support deeply nested Autocomplete