feat: throw error on plugin usage for event listeners

This commit is contained in:
Jacob Nguyen
2022-06-27 13:20:00 -05:00
parent a6d309ab5a
commit 9271f103ea
2 changed files with 7 additions and 8 deletions

View File

@@ -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,

View File

@@ -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`,
}