mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
feat: revamp module types to support event plugins
This commit is contained in:
@@ -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<void | unknown>;
|
||||
}
|
||||
>;
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user