import type { ApplicationCommandOptionData, Awaitable, ButtonInteraction, MessageContextMenuCommandInteraction, SelectMenuInteraction, UserContextMenuCommandInteraction, } from 'discord.js'; import type { Args, Override } from '../../types/handler'; import type { CommandPlugin, EventPlugin } from '../plugins/plugin'; import type Context from './context'; import { CommandType, PluginType } from './enums'; export interface BaseModule { type: CommandType | PluginType; name?: string; description: string; execute: (ctx: Context, args: Args) => Awaitable; } //possible refactoring types into interfaces and not types export type TextCommand = Override[] plugins?: CommandPlugin[]; alias?: string[]; }>; export type SlashCommand = Override[] plugins?: CommandPlugin[]; options?: ApplicationCommandOptionData[]; }>; export type BothCommand = Override[] plugins?: CommandPlugin[] alias?: string[]; options?: ApplicationCommandOptionData[]; }>; export type ContextMenuUser = Override[]; plugins?: CommandPlugin[]; execute: (ctx: UserContextMenuCommandInteraction) => Awaitable }> export type ContextMenuMsg = Override[]; plugins?: CommandPlugin[]; execute: (ctx: MessageContextMenuCommandInteraction) => Awaitable }>; export type ButtonCommand = Override[]; plugins?: CommandPlugin[]; execute: (ctx: ButtonInteraction) => Awaitable }>; export type SelectMenuCommand = Override[]; plugins?: CommandPlugin[]; execute: (ctx: SelectMenuInteraction) => Awaitable }>; export type Module = | TextCommand | SlashCommand | BothCommand | ContextMenuUser | ContextMenuMsg | ButtonCommand | SelectMenuCommand; //https://stackoverflow.com/questions/64092736/alternative-to-switch-statement-for-typescript-discriminated-union // Explicit Module Definitions for mapping export type ModuleDefs = { [CommandType.Text]: TextCommand; [CommandType.Slash]: SlashCommand; [CommandType.Both]: BothCommand; [CommandType.MenuMsg]: ContextMenuMsg; [CommandType.MenuUser]: ContextMenuUser; [CommandType.Button]: ButtonCommand; [CommandType.MenuSelect]: SelectMenuCommand; };