Something went wrong. Try again.
Yet another Fluxer bot built with TypeScript and Bun
Something went wrong. Try again.
720 B · 22 lines
TypeScript
at develop
1234567891011121314151617181920212223import "reflect-metadata";import type { ArgSchema } from "@/args";import { MODULE_COMMANDS_KEY } from "@/base/ModuleBase";
export interface CommandMeta { name: string; aliases?: string[]; description: string; args?: ArgSchema;}
export const COMMAND_META_KEY = Symbol("fluxer:command");
export function Command(meta: CommandMeta): MethodDecorator { return (_target, methodName) => { if (typeof methodName !== "string") return; const commands: Array<{ methodName: string; meta: CommandMeta }> = Reflect.getMetadata(MODULE_COMMANDS_KEY, _target.constructor) ?? []; commands.push({ methodName, meta }); Reflect.defineMetadata(MODULE_COMMANDS_KEY, commands, _target.constructor); };}