From 9271f103eafe118213ae5b3d714aed949bf4de7e Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Mon, 27 Jun 2022 13:20:00 -0500 Subject: [PATCH] feat: throw error on plugin usage for event listeners --- src/handler/sern.ts | 13 ++++++------- src/handler/structures/errors.ts | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/handler/sern.ts b/src/handler/sern.ts index feaa609..5bbcc36 100644 --- a/src/handler/sern.ts +++ b/src/handler/sern.ts @@ -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, diff --git a/src/handler/structures/errors.ts b/src/handler/structures/errors.ts index 86a90b0..6d6a898 100644 --- a/src/handler/structures/errors.ts +++ b/src/handler/structures/errors.ts @@ -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`, }