mirror of
https://github.com/SrIzan10/handler.git
synced 2026-05-01 10:45:17 +00:00
feat: adding ModuleConfiguration helper fn and default module manager
This commit is contained in:
@@ -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);
|
||||
}
|
||||
15
src/handler/structures/defaultModuleManager.ts
Normal file
15
src/handler/structures/defaultModuleManager.ts
Normal 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 {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user