fix: Crash on interactionCreate event

This commit is contained in:
Jacob Nguyen
2022-06-24 10:45:52 -05:00
parent 8e037988d5
commit dea8fc05b1
3 changed files with 11 additions and 10 deletions

View File

@@ -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": {

View File

@@ -48,7 +48,7 @@ export function onReady(wrapper: Wrapper) {
(
concat(ready$, processPlugins$) as Observable<{
mod: DefinedCommandModule;
cmdPluginsRes: {
cmdPluginRes: {
execute: Awaitable<Result<void, void>>;
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);

View File

@@ -51,15 +51,16 @@ export function processCommandPlugins$<T extends DefinedModule>(
type: P.not(CommandType.Autocomplete),
plugins: P.array({} as P.infer<CommandPlugin>),
},
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(