diff --git a/src/handler/sern/sern.ts b/src/handler/sern/sern.ts index 0a9b07c..15f3b91 100644 --- a/src/handler/sern/sern.ts +++ b/src/handler/sern/sern.ts @@ -1,7 +1,7 @@ import type { MessagePackage, Nullable, Visibility } from "../../types/handler/handler"; import { CommandType } from "../../types/handler/handler"; import { Files } from "../utils/readFile" -import type { ApplicationCommand, ApplicationCommandOption, ApplicationCommandOptionData, Awaitable, Client, CommandInteraction, CommandInteractionOption, Message, MessageInteraction, Util } from "discord.js"; +import type { ApplicationCommandOptionData, Awaitable, Client, CommandInteraction, CommandInteractionOptionResolver, Message} from "discord.js"; import type { possibleOutput } from "../../types/handler/handler" import { Err, Ok, Result, Option, None, Some } from "ts-results"; import type { Utils } from "../utils/preprocessors/args"; @@ -60,9 +60,11 @@ export namespace Sern { description : module.mod.desc, options: module.options }); + if(module.mod.type === CommandType.SLASH) return "This is not a slash command"; + + let parsedArgs = module.mod.parse?.({message: None, interaction: Some(interaction)}, interaction.options ?? []) ?? Ok([]); + module.mod.delegate({message : None, interaction: Some(interaction)}, Ok(parsedArgs) ); - module.mod.delegate({message : None, interaction: Some(interaction)}, Ok(interaction.options) ); - throw Error("unimpl") } private async commandResult(module: Sern.Module | undefined, message: Message) : Promise { @@ -117,7 +119,11 @@ export namespace Sern { message : Option, interaction : Option } - + type MapArgTypes = { + 2 : Omit, + 4: string + 6: MapArgTypes["2"] | MapArgTypes["4"] + } export interface Module { alias: string[], @@ -125,7 +131,7 @@ export namespace Sern { visibility : Visibility, type: CommandType, delegate : ( eventParams : Context , args: Ok ) => Awaitable | void> - parse? : (message: Context, args: string) => Utils.ArgType + parse? : ["type"]>(ctx: Context, args: MapArgTypes[C] ) => Utils.ArgType } diff --git a/src/handler/utils/readFile.ts b/src/handler/utils/readFile.ts index 3988044..7ba1633 100644 --- a/src/handler/utils/readFile.ts +++ b/src/handler/utils/readFile.ts @@ -38,7 +38,7 @@ export namespace Files { const options = ((await import(absPath)).options as ApplicationCommandOptionData[]) Commands.set(name.substring(0, name.length - 3), { mod, options : options ?? [] }); } break; - case 6 : { + case 2 | 4 : { const options = ((await import(absPath)).options as ApplicationCommandOptionData[]) Commands.set(name.substring(0, name.length-3),{mod, options : options ?? [] } ); } break; diff --git a/src/types/handler/handler.ts b/src/types/handler/handler.ts index 4a2ba2b..f591372 100644 --- a/src/types/handler/handler.ts +++ b/src/types/handler/handler.ts @@ -16,6 +16,6 @@ export type MessagePackage = { export type delegate = Sern.Module["delegate"] export enum CommandType { - TEXT = 1 << 1, - SLASH = 1 << 2, + TEXT = 2, + SLASH = 4, } \ No newline at end of file