diff --git a/src/commands/build.ts b/src/commands/build.ts index 6f50e23..bee52e7 100644 --- a/src/commands/build.ts +++ b/src/commands/build.ts @@ -174,21 +174,22 @@ export async function build(options: Record) { ${commandsPaths.map((imp, i) => { if(i === 0) { return `if(interaction.data.name === "${p.parse(imp).name}") { - const success = await applyPlugins(${p.parse(imp).name}); + const data = createContext(interaction) + const success = await applyPlugins(${p.parse(imp).name}, data); if(success) { - await ${p.parse(imp).name}.execute(); + await ${p.parse(imp).name}.execute(data); } }` } return `else if(interaction.data.name === "${p.parse(imp).name}" ) { - const success = await applyPlugins(${p.parse(imp).name}); - if(success) { - await ${p.parse(imp).name}.execute(); - } - }` - }).join("\n")} - `); - + const data = createContext(interaction) + const success = await applyPlugins(${p.parse(imp).name}, data); + if(success) { + await ${p.parse(imp).name}.execute(data); + } + }` + }).join("\n")}`.trim()); + await writeFile("./dist/out.js", importedModulesTemplate); } else { diff --git a/templates/cf.js b/templates/cf.js index f9283a8..718be84 100644 --- a/templates/cf.js +++ b/templates/cf.js @@ -20,7 +20,9 @@ class JsonResponse extends Response { super(jsonBody, init); } } - +function createContext(rawcontext) { + return rawcontext +} async function executeModule( emitter, logger, @@ -40,7 +42,7 @@ async function applyPlugins(module, payload) { let success = true; for (const plg of module.onEvent){ const res = await plg.execute(payload); - if(!res.ok) { + if(!res.isOk()) { success = false; } }