diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index 52ed9a9..3abaec4 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -28,40 +28,41 @@ export enum PluginType { Event = 0b10, } -type executeCmdPlugin = { execute: (wrapper: Wrapper, controller: Controller) => Result }; +type executeCmdPlugin = (controller: Controller) => Result ; -interface BasePlugin extends Override { - type: PluginType; -} +type BasePlugin = Override; -export type CommandPlugin = { +export type CommandPlugin = Override Awaitable>; - }>; + execute: (wrapper: Client, module: Module, controller: Controller) => Awaitable>; +}>; //TODO: rn adding the modType check a little hackish. Find better way to determine the // module type of the event plugin -export type EventPlugin = { +export type EventPlugin = Override, controller: Controller) => Awaitable>; - }>; + execute: (event: Parameters, controller: Controller) => Awaitable>; +}>; -export function plugins(...plug: CommandPlugin[]): CommandPlugin[]; -export function plugins(...plug: EventPlugin[]): EventPlugin[]; -export function plugins(...plug: CommandPlugin[] | EventPlugin[]) { +export function plugins(...plug: (CommandPlugin | EventPlugin)[]) { return plug; } -export function sernModule(plugins : CommandPlugin[], onEvent: EventPlugin[], mod: Omit) { - // return { - // plugins, - // onEvent, - // ...mod, - // }; +export function sernModule( + plugs: (CommandPlugin | EventPlugin)[], mod : ModuleDefs[T] +) : ModuleDefs[T] { + //mod.plugins if defined, warn user to use first parameter + //mod.onEvent if defined, warn user to use first parameter + const plugins = plugs.filter(el => el.type === PluginType.Command); + const onEvent = plugs.filter(el => el.type === PluginType.Event); + return { + plugins, + onEvent, + ...mod + } as unknown as ModuleDefs[T]; }