diff --git a/package.json b/package.json index 22b701b..f203e12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sern/handler", - "version": "1.0.1-beta", + "version": "1.0.2-beta", "description": "A customizable, batteries-included, powerful discord.js framework to automate and streamline bot development.", "main": "dist/index.js", "scripts": { diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index 13b1292..e562b00 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -48,7 +48,7 @@ export function onReady(wrapper: Wrapper) { ( concat(ready$, processPlugins$) as Observable<{ mod: DefinedCommandModule; - cmdPluginsRes: { + cmdPluginRes: { execute: Awaitable>; type: PluginType.Command; name: string; @@ -57,14 +57,14 @@ export function onReady(wrapper: Wrapper) { }> ) .pipe( - concatMap(pl => - from( + concatMap(pl => { + return from( //refactor, this allocates too many objects Promise.all( - pl.cmdPluginsRes.map(async e => ({ ...e, execute: await e.execute })), + pl.cmdPluginRes.map(async e => ({ ...e, execute: await e.execute })), ), - ).pipe(map(res => ({ ...pl, cmdPluginsRes: res }))), - ), + ).pipe(map(res => ({ ...pl, cmdPluginsRes: res }))); + }), ) .subscribe(({ mod, cmdPluginsRes }) => { const loadedPluginsCorrectly = cmdPluginsRes.every(({ execute }) => execute.ok); diff --git a/src/handler/events/userDefinedEventsHandling.ts b/src/handler/events/userDefinedEventsHandling.ts index e706943..98823ef 100644 --- a/src/handler/events/userDefinedEventsHandling.ts +++ b/src/handler/events/userDefinedEventsHandling.ts @@ -51,15 +51,16 @@ export function processCommandPlugins$( type: P.not(CommandType.Autocomplete), plugins: P.array({} as P.infer), }, - m => - Ok( + m => { + return Ok( m.plugins.map(plug => ({ ...plug, name: plug?.name ?? 'Unnamed Plugin', description: plug?.description ?? '...', execute: plug.execute(client, m, controller), })), - ), + ); + }, ) .otherwise(() => Err(