From 9e93d38f05e74f4347debf55cface9921027536b Mon Sep 17 00:00:00 2001 From: jacoobes Date: Wed, 9 Feb 2022 22:11:13 -0600 Subject: [PATCH] slashCommand refresh impl starting --- src/handler/sern.ts | 13 ++++--------- src/handler/utils/readFile.ts | 8 ++++++++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/handler/sern.ts b/src/handler/sern.ts index b9f03f5..fa7dec9 100644 --- a/src/handler/sern.ts +++ b/src/handler/sern.ts @@ -24,8 +24,8 @@ export class Handler { this.wrapper.client .on("ready", async () => { - if (this.wrapper.init !== undefined) this.wrapper.init(this); await Files.registerModules(this); + if (this.wrapper.init !== undefined) this.wrapper.init(this); }) .on("messageCreate", async message => { @@ -69,23 +69,18 @@ export class Handler { if (parsedArgs.err) return parsedArgs.val; const fn = await module.mod.delegate(context, parsedArgs); return fn?.val; - } - + } private async commandResult(module: Files.CommandVal | undefined, message: Message, args: string): Promise { if (module?.mod === undefined) return "Unknown legacy command"; - + if (module.mod.type === CommandType.SLASH) return `This may be a slash command and not a legacy command` if (module.mod.visibility === "private") { const checkIsTestServer = this.privateServers.find(({id}) => id === message.guildId!)?.test; if(checkIsTestServer === undefined) return "This command has the private modifier but is not registered under Handler#privateServers"; if(checkIsTestServer !== module.testOnly) { return "This private command is a testing command"; } - } - - - - if (module.mod.type === CommandType.SLASH) return `This may be a slash command and not a legacy command` + } const context = { message: Some(message), interaction: None } const parsedArgs = module.mod.parse?.(context, ["text", args]) ?? Ok(""); if (parsedArgs.err) return parsedArgs.val; diff --git a/src/handler/utils/readFile.ts b/src/handler/utils/readFile.ts index 73439c6..c8afc7a 100644 --- a/src/handler/utils/readFile.ts +++ b/src/handler/utils/readFile.ts @@ -44,6 +44,14 @@ export async function registerModules(handler: Sern.Handler): Promise { case (1 | 2): { const options = ((await import(absPath)).options as ApplicationCommandOptionData[]) Commands.set(cmdName, { mod, options: options ?? [], testOnly }); + switch(mod.visibility) { + case "private" : { + //unimplemented + } + case "public" : { + //unimplemented + } + } } break; default: throw Error(`${name}.js is not a valid module type.`); }