feat: adding ModuleConfiguration helper fn and default module manager

This commit is contained in:
Jacob Nguyen
2022-08-26 00:06:16 -05:00
parent 9b51fc0c56
commit f993e3fd66
2 changed files with 26 additions and 1 deletions

View File

@@ -3,7 +3,7 @@ import { Err, Ok } from 'ts-results-es';
import { ExternalEventEmitters } from './utilities/readFile';
import type { EventEmitter } from 'events';
import { processEvents } from './events/userDefinedEventsHandling';
import { EventType, PluginType } from './structures/enums';
import { CommandType, EventType, PluginType } from './structures/enums';
import type {
CommandPlugin,
EventModuleCommandPluginDefs,
@@ -17,6 +17,9 @@ import InteractionHandler from './events/interactionHandler';
import ReadyHandler from './events/readyHandler';
import MessageHandler from './events/messageHandler';
import type { CommandModule, EventModule } from '../types/module';
import type { ModuleStore } from './structures/moduleStore';
import type { Client } from 'discord.js';
import type { ModuleConfig, ModuleManagerConstructor } from './contracts/moduleManager';
/**
*
@@ -119,3 +122,10 @@ export function eventModule(mod: InputEventModule): EventModule {
plugins,
} as EventModule;
}
export function ModuleConfiguration<T extends ModuleStore>(
moduleManager : ModuleManagerConstructor<T>,
moduleStore: T,
) : ModuleConfig<T> {
return ( client: Client ) => new moduleManager(client, moduleStore);
}

View File

@@ -0,0 +1,15 @@
import ModuleManager from '../contracts/moduleManager';
import type { CommandModule, CommandModuleDefs } from '../../types/module';
import type { CommandType } from './enums';
export class DefaultModuleManager extends ModuleManager {
getModule<T extends CommandType>(type: T, name: string): CommandModuleDefs[T] | undefined {
return undefined;
}
setModule<T extends CommandType>(type: T, value: CommandModule): void {
}
}