From e1f884356d8270ea6d140e2a053e546f43670b19 Mon Sep 17 00:00:00 2001 From: Arcs <73959934+HighArcs@users.noreply.github.com> Date: Fri, 9 Sep 2022 21:16:20 -0500 Subject: [PATCH 1/4] Update readFile.ts --- src/handler/utilities/readFile.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/handler/utilities/readFile.ts b/src/handler/utilities/readFile.ts index 1f12eeef..dad072ef 100644 --- a/src/handler/utilities/readFile.ts +++ b/src/handler/utilities/readFile.ts @@ -73,6 +73,11 @@ export function buildData(commandDir: string): Observable< } catch { mod = (await import(`file:///` + absPath)).default; } + + try { + mod = new mod(); + } catch {} + if (mod !== undefined) { return Ok({ mod, absPath }); } else return Err(SernError.UndefinedModule); From 0134109e9b74892c089ff95cb9b5a24c8bcb6c39 Mon Sep 17 00:00:00 2001 From: Arcs <73959934+HighArcs@users.noreply.github.com> Date: Fri, 9 Sep 2022 21:32:50 -0500 Subject: [PATCH 2/4] Update userDefinedEventsHandling.ts --- src/handler/events/userDefinedEventsHandling.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handler/events/userDefinedEventsHandling.ts b/src/handler/events/userDefinedEventsHandling.ts index fa02698c..5293520e 100644 --- a/src/handler/events/userDefinedEventsHandling.ts +++ b/src/handler/events/userDefinedEventsHandling.ts @@ -25,7 +25,7 @@ export function processCommandPlugins( wrapper: Wrapper, payload: { mod: T; absPath: string }, ) { - return payload.mod.plugins.map(plug => ({ + return (payload.mod.plugins || []).map(plug => ({ ...plug, name: plug?.name ?? 'Unnamed Plugin', description: plug?.description ?? '...', From ad94114d91119353bc20384478c42675c621266e Mon Sep 17 00:00:00 2001 From: Arcs <73959934+HighArcs@users.noreply.github.com> Date: Fri, 9 Sep 2022 21:33:15 -0500 Subject: [PATCH 3/4] Update readyHandler.ts --- src/handler/events/readyHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handler/events/readyHandler.ts b/src/handler/events/readyHandler.ts index 1a5318e5..83e02dcf 100644 --- a/src/handler/events/readyHandler.ts +++ b/src/handler/events/readyHandler.ts @@ -87,7 +87,7 @@ export default class ReadyHandler extends EventsHandler<{ type: PluginType.Command; }[]; }) { - if (mod.plugins.length === 0) { + if ((mod.plugins || []).length === 0) { return of({ mod, pluginRes: [] }); } // modules with no event plugins are ignored in the previous From 8a64c0be0f6cceb8f6b2a32d8a6466a62ef614bb Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sat, 10 Sep 2022 13:07:11 -0500 Subject: [PATCH 4/4] fix: ts error --- src/handler/utilities/readFile.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handler/utilities/readFile.ts b/src/handler/utilities/readFile.ts index dad072ef..47497bf8 100644 --- a/src/handler/utilities/readFile.ts +++ b/src/handler/utilities/readFile.ts @@ -75,7 +75,7 @@ export function buildData(commandDir: string): Observable< } try { - mod = new mod(); + mod = new (mod as unknown as new (...args: unknown[]) => T)(); } catch {} if (mod !== undefined) {