Yet another Fluxer bot built with TypeScript and Bun
at better-command-system 31 lines 754 B view raw
1import "reflect-metadata"; 2import { Message } from "@fluxerjs/core"; 3import type { ArgSchema } from "@/args"; 4 5export interface ModuleMeta { 6 name: string; 7 description?: string; 8} 9 10export const MODULE_META_KEY = Symbol("fluxer:module"); 11export const MODULE_COMMANDS_KEY = Symbol("fluxer:module-commands"); 12 13export interface CommandMethodMeta { 14 name: string; 15 aliases?: string[]; 16 description: string; 17 args?: ArgSchema; 18} 19 20export interface ModuleCommand { 21 methodName: string; 22 meta: CommandMethodMeta; 23} 24 25export type Guard = (msg: Message) => boolean | Promise<boolean>; 26 27export function Module(meta: ModuleMeta & { guards?: Guard[] }): ClassDecorator { 28 return (target) => { 29 Reflect.defineMetadata(MODULE_META_KEY, meta, target); 30 }; 31}