mirror of
https://github.com/sern-handler/handler
synced 2026-06-20 23:02:15 +00:00
fix: Crash on interactionCreate event
This commit is contained in:
@@ -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": {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user