diff --git a/src/handler/structures/commands/command-creator.ts b/src/handler/structures/commands/command-creator.ts deleted file mode 100644 index 8b13789..0000000 --- a/src/handler/structures/commands/command-creator.ts +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/handler/structures/commands/command-options.ts b/src/handler/structures/commands/command-options.ts deleted file mode 100644 index 7874b3b..0000000 --- a/src/handler/structures/commands/command-options.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { ApplicationCommandOptionData } from 'discord.js'; -import type { CommandType } from '../../sern'; - -/** - * An object that gets imported and acts as a command. - * @typedef {object} Module - * @property {string} desc - * @property {CommandType} type - * @property {(eventParams : Context, args : Ok Awaitable)} execute - * @prop {(ctx: Context, args: Arg) => Utils.ArgType} parse - */ - -interface CommandOptions { - commandType : CommandType, - alias : string[] | [], - options?: ApplicationCommandOptionData[], - name? : string | undefined -} - -export default CommandOptions; diff --git a/src/handler/structures/commands/command.ts b/src/handler/structures/commands/command.ts deleted file mode 100644 index 8c096d9..0000000 --- a/src/handler/structures/commands/command.ts +++ /dev/null @@ -1,48 +0,0 @@ -import type { ApplicationCommandOptionData, Awaitable } from "discord.js"; -import type { possibleOutput, Arg } from "../../../types/handler"; -import Context from "../context"; -import type * as Utils from '../../utilities/preprocessors/args'; -import { None, Ok } from "ts-results"; -import { CommandType } from "../../sern"; -import { SernError } from "../errors"; -import type CommandOptions from "./command-options"; - - -export abstract class Command { - - private name? : string | undefined; - private ctx : Context = new Context( None, None ); - private commandType : CommandType; - private options : ApplicationCommandOptionData[] | undefined; - private alias : string[] | undefined; - private constructor ( - { name, commandType, options, alias } : CommandOptions - ) { - this.name = name; - this.commandType = commandType; - switch ( commandType ) { - case CommandType.TEXT : { - this.options = undefined; - this.alias = alias; - } break; - case CommandType.SLASH : { - if(alias.length < 0) throw Error(SernError.NO_ALIAS); - this.options = options; - } break; - case CommandType.BOTH : { - this.options = options; - this.alias = alias; - } break - - - } - } - - abstract execute ( args: Ok ) : Awaitable; - abstract parse? ( args: Arg ) : Utils.ArgType; - public setCtx ( context: Context ) { this.ctx = context; } - public getName () { return this.name; } - public getCommandType () { return this.commandType; } - public getOptions() { return this.options; } - public getAlias() { return this.alias } -} diff --git a/src/handler/structures/commands/module.ts b/src/handler/structures/commands/module.ts new file mode 100644 index 0000000..4b4386e --- /dev/null +++ b/src/handler/structures/commands/module.ts @@ -0,0 +1,32 @@ +import type { ApplicationCommandOptionData, Awaitable } from "discord.js"; +import type { possibleOutput } from "../../../types/handler"; +import type { CommandType } from "../../sern"; + + + +interface BaseModule { + name? : string; + description : string; + execute() : Awaitable + plugins? : [] //TODO +} + +type TextCommand = { moduleType : CommandType.TEXT; alias : string[] | [] }; +type SlashCommand = { moduleType : CommandType.SLASH; options : ApplicationCommandOptionData[] | [] }; +type BothCommand = { moduleType : CommandType.BOTH; alias : string[] | []; options : ApplicationCommandOptionData[] | [] } + +export type Module = + BaseModule & ( + TextCommand + | SlashCommand + | BothCommand + ); + + + + + + + + +