mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
feat: throw error on plugin usage for event listeners
This commit is contained in:
@@ -16,6 +16,7 @@ import type {
|
||||
InputCommandModule,
|
||||
InputEventModule,
|
||||
} from './plugins/plugin';
|
||||
import { SernError } from './structures/errors';
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -71,14 +72,12 @@ export function commandModule(mod: InputCommandModule): CommandModule {
|
||||
export function eventModule(mod: InputEventModule): EventModule {
|
||||
const onEvent: EventModuleEventPluginDefs[EventType][] = [];
|
||||
const plugins: EventModuleCommandPluginDefs[EventType][] = [];
|
||||
for (const pl of mod.plugins ?? []) {
|
||||
if (pl.type === PluginType.Event) {
|
||||
onEvent.push(pl);
|
||||
} else {
|
||||
plugins.push(pl);
|
||||
}
|
||||
const hasPlugins = mod.plugins && mod.plugins.length > 0;
|
||||
if (hasPlugins) {
|
||||
throw Error(
|
||||
SernError.NotSupportedYet + `: Plugins on event listeners are not supported yet`,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
...mod,
|
||||
onEvent,
|
||||
|
||||
@@ -5,5 +5,5 @@ export enum SernError {
|
||||
NotSupportedInteraction = `This interaction is not supported.`,
|
||||
PluginFailure = `A plugin failed to call controller.next()`,
|
||||
MismatchEvent = `You cannot use message when an interaction fired or vice versa`,
|
||||
UndefinedSernEmitter = `Could not find an Emitter`,
|
||||
NotSupportedYet = `This feature is not supported yet`,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user