mirror of
https://github.com/sern-handler/handler
synced 2026-06-24 16:52:15 +00:00
revert: Re-add plugins overload
This commit is contained in:
@@ -118,7 +118,7 @@ export function onInteractionCreate (wrapper: Wrapper) {
|
||||
}),
|
||||
).subscribe({
|
||||
next({m, res, execute}) {
|
||||
console.log(res);
|
||||
|
||||
},
|
||||
error(err) {
|
||||
console.log(err);
|
||||
|
||||
@@ -43,9 +43,6 @@ export const onMessageCreate = (wrapper: Wrapper) => {
|
||||
concatMap(({ ctx, args, mod }) => {
|
||||
const res = Promise.all(
|
||||
mod.onEvent?.map(ePlug => {
|
||||
if ((ePlug.modType & mod.type) === 0) {
|
||||
return Err.EMPTY;
|
||||
}
|
||||
return ePlug.execute([ctx, args], controller);
|
||||
}) ?? [],
|
||||
);
|
||||
|
||||
@@ -17,6 +17,7 @@ import type { Module, Override } from '../..';
|
||||
import type { BaseModule, ModuleDefs } from '../structures/module';
|
||||
import type { PluginType } from '../structures/enums';
|
||||
import type { ValueOf } from 'ts-pattern/dist/types/helpers';
|
||||
import type { CommandType } from '../..';
|
||||
|
||||
|
||||
export interface Controller {
|
||||
@@ -40,7 +41,9 @@ export type EventPlugin<T extends keyof ModuleDefs> = Override<BasePlugin, {
|
||||
execute: (event: Parameters<ModuleDefs[T]['execute']>, controller: Controller) => Awaitable<Result<void, void>>;
|
||||
}>;
|
||||
|
||||
export function plugins(...plug: CommandPlugin[]) {
|
||||
export function plugins(...plug: CommandPlugin[]) : CommandPlugin[];
|
||||
export function plugins<T extends keyof ModuleDefs>(...plug: EventPlugin<T>[]) : EventPlugin<T>[];
|
||||
export function plugins<T extends keyof ModuleDefs>(...plug: EventPlugin<T>[] | CommandPlugin[]) {
|
||||
return plug;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ export function isUserContextMenuCmd(i : CommandInteraction) : i is UserContextM
|
||||
return i.isUserContextMenuCommand();
|
||||
}
|
||||
|
||||
function isPromise<T>(promiseLike : Awaitable<T>) : promiseLike is Promise<T> {
|
||||
export function isPromise<T>(promiseLike : Awaitable<T>) : promiseLike is Promise<T> {
|
||||
const keys = new Set(Object.keys(promiseLike));
|
||||
return keys.has('then') && keys.has('catch');
|
||||
}
|
||||
Reference in New Issue
Block a user