mirror of
https://github.com/sern-handler/handler
synced 2026-06-15 20:32:14 +00:00
refactor: move and update things
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { CommandModuleDefs } from '../../types/module';
|
||||
import type { CommandModule, CommandModuleDefs } from '../../types/module';
|
||||
import type { CommandType, ModuleStore } from '../structures';
|
||||
import type { Processed } from '../../types/handler';
|
||||
/**
|
||||
@@ -25,3 +25,16 @@ export class DefaultModuleManager implements ModuleManager {
|
||||
strat(this.moduleStore);
|
||||
}
|
||||
}
|
||||
|
||||
export type ModuleGetter = (accessStrat: (ms: ModuleStore) => Processed<CommandModule>|undefined) => Processed<CommandModule>|undefined
|
||||
export function createModuleGetter(moduleManager: ModuleManager) {
|
||||
return (accessStrat: (ms: ModuleStore) => Processed<CommandModule>|undefined) => {
|
||||
return moduleManager.get(accessStrat)
|
||||
}
|
||||
}
|
||||
|
||||
export function createModuleInserter(moduleManager: ModuleManager) {
|
||||
return (insertStrat: (ms: ModuleStore) => void) => {
|
||||
return moduleManager.set(insertStrat)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ export function buildModuleStream<T>(
|
||||
export function getCommands(dir: string): string[] {
|
||||
return readPath(join(process.cwd(), dir));
|
||||
}
|
||||
|
||||
export function filename(path: string) {
|
||||
return fmtFileName(basename(path))
|
||||
}
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
|
||||
import { concatMap, defaultIfEmpty, EMPTY, every, fromEvent, map, Observable, of, OperatorFunction, pipe, share } from 'rxjs';
|
||||
import type { AnyModule } from '../types/module';
|
||||
import { nameOrFilename } from './utilities/functions';
|
||||
import type { PluginResult, VoidResult } from '../types/plugin';
|
||||
import { Result } from 'ts-results-es';
|
||||
import { ImportPayload } from '../types/handler';
|
||||
import { ImportPayload, Processed } from '../types/handler';
|
||||
import { EventEmitter } from 'node:events';
|
||||
/**
|
||||
* if {src} is true, mapTo V, else ignore
|
||||
@@ -40,14 +39,11 @@ export function callPlugin(args: unknown): OperatorFunction<
|
||||
export const arrayifySource = map(src => (Array.isArray(src) ? (src as unknown[]) : [src]));
|
||||
|
||||
export const fillDefaults = <T extends AnyModule>({ module, absPath }: ImportPayload<T>) => {
|
||||
module.description ??= '...'
|
||||
return {
|
||||
absPath,
|
||||
module: {
|
||||
name: nameOrFilename(module?.name, absPath),
|
||||
description: module?.description ?? '...',
|
||||
...module,
|
||||
},
|
||||
};
|
||||
module
|
||||
} as ImportPayload<Processed<T>>;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
19
src/index.ts
19
src/index.ts
@@ -1,18 +1,9 @@
|
||||
import SernEmitter from './handler/sernEmitter';
|
||||
export {
|
||||
eventModule,
|
||||
commandModule,
|
||||
EventExecutable,
|
||||
CommandExecutable,
|
||||
controller,
|
||||
discordEvent,
|
||||
} from './handler/sern';
|
||||
export { default as SernEmitter } from './core/sernEmitter';
|
||||
export * as Sern from './handler/sern';
|
||||
export * from './types/handler';
|
||||
export * from './types/module';
|
||||
export * from './types/plugin';
|
||||
export * from './handler/structures';
|
||||
export * from './handler/plugins';
|
||||
export * from './handler/contracts';
|
||||
export { SernEmitter };
|
||||
export * from './handler/dependencies';
|
||||
export * from './core'
|
||||
export { controller } from './handler/sern'
|
||||
export { commandModule, eventModule, CommandExecutable, EventExecutable } from './commands'
|
||||
export { default as Context } from './classic/context'
|
||||
|
||||
Reference in New Issue
Block a user