diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index a85ca5b..43c562c 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -13,7 +13,7 @@ // import type { Err, Ok, Result } from "ts-results"; -import type { Override } from "../.."; +import type { Override, Wrapper } from "../.."; import type { BaseModule } from "../structures/modules/module"; export enum PluginType { @@ -33,15 +33,15 @@ interface BasePlugin extends Override{ type : PluginType } -type CommandPlugin = { +export type CommandPlugin = { type : PluginType.Command -} & BasePlugin; +} & Override Result}>; -type EventPlugin = { +export type EventPlugin = { type : PluginType.Event } & BasePlugin; -export type Plugin = +export type SernPlugin = CommandPlugin | EventPlugin; diff --git a/src/handler/structures/modules/module.ts b/src/handler/structures/modules/module.ts index 33bd905..ed75ebc 100644 --- a/src/handler/structures/modules/module.ts +++ b/src/handler/structures/modules/module.ts @@ -1,5 +1,6 @@ import type { Awaitable, ChatInputCommandInteraction, Interaction } from "discord.js"; import type { Args, Module } from "../../.."; +import type { CommandPlugin, EventPlugin, SernPlugin } from "../../plugins/plugin"; import type Context from "../context"; export interface BaseModule { @@ -8,8 +9,27 @@ export interface BaseModule { execute: (ctx: Context, args: Args) => Awaitable; } - -export function sernModule (module : T, plugins : Plugin[]) { - - +export interface PluggedModule { + mod : T; + plugins : SernPlugin[]; +} + +export function commmand ( plug : CommandPlugin ) { + return plug; +} + +export function event( plug : EventPlugin ) { + return plug; +} + +export function apply(...plugins: SernPlugin[]) { + return plugins; +} + +export function sernModule + (plugins : () => SernPlugin[], mod : T, ) : PluggedModule { + return { + mod, + plugins : plugins() + } }