mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
fix: ioc deps not created correctly
This commit is contained in:
@@ -51,7 +51,6 @@ type ValidDependencyConfig =
|
||||
|
||||
export async function makeDependencies (conf: ValidDependencyConfig) {
|
||||
const container = await __init_container({ autowire: false });
|
||||
conf(dependencyBuilder(container));
|
||||
//We only include logger if it does not exist
|
||||
const includeLogger = !container.hasKey('@sern/logger');
|
||||
|
||||
@@ -62,6 +61,7 @@ export async function makeDependencies (conf: ValidDependencyConfig) {
|
||||
__add_container('@sern/modules', new Map)
|
||||
__add_container('@sern/emitter', new EventEmitter)
|
||||
__add_wiredcontainer('@sern/cron', deps => new __Services.Cron(deps))
|
||||
conf(dependencyBuilder(container));
|
||||
await container.ready();
|
||||
}
|
||||
|
||||
|
||||
@@ -89,3 +89,4 @@ export async function Asset(p: string, opts?: { name?: string, encoding: AssetEn
|
||||
return fs.readFile(filePath, encoding);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
14
src/sern.ts
14
src/sern.ts
@@ -10,7 +10,6 @@ import { handleCrash } from './handlers/event-utils';
|
||||
import { useContainerRaw } from './core/ioc/global';
|
||||
import { UnpackedDependencies } from './types/utility';
|
||||
import type { PresenceResult } from './core/presences';
|
||||
import fs from 'fs/promises'
|
||||
|
||||
interface Wrapper {
|
||||
commands: string;
|
||||
@@ -64,16 +63,3 @@ export function init(maybeWrapper: Wrapper = { commands: "./dist/commands" }) {
|
||||
// listening to the message stream and interaction stream
|
||||
merge(messages$, interactions$).pipe(handleCrash(deps)).subscribe();
|
||||
}
|
||||
|
||||
|
||||
export async function publisher() {
|
||||
const directoryToWatch = "./src/commands";
|
||||
const watcher = fs.watch(directoryToWatch, { recursive: true }, );
|
||||
for await (const { eventType, filename } of watcher) {
|
||||
switch(eventType) {
|
||||
case 'change': {
|
||||
console.log('change', filename)
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,20 +38,17 @@ export interface InitArgs<T extends Processed<Module> = Processed<Module>> {
|
||||
module: T;
|
||||
absPath: string;
|
||||
deps: Dependencies
|
||||
updateModule: (module: Partial<T>) => T
|
||||
}
|
||||
export interface Plugin<Args extends any[] = any[]> {
|
||||
type: PluginType;
|
||||
execute: (...args: Args) => PluginResult;
|
||||
}
|
||||
|
||||
export interface InitPlugin<Args extends any[] = any[]> {
|
||||
export interface InitPlugin<Args extends any[] = any[]> extends Plugin<Args> {
|
||||
type: PluginType.Init;
|
||||
execute: (...args: Args) => PluginResult;
|
||||
}
|
||||
export interface ControlPlugin<Args extends any[] = any[]> {
|
||||
export interface ControlPlugin<Args extends any[] = any[]> extends Plugin<Args> {
|
||||
type: PluginType.Control;
|
||||
execute: (...args: Args) => PluginResult;
|
||||
}
|
||||
|
||||
export type AnyPlugin = ControlPlugin | InitPlugin<[InitArgs<Processed<Module>>]>;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { InteractionReplyOptions, MessageReplyOptions } from 'discord.js';
|
||||
import type { PayloadType } from '../core/structures/enums';
|
||||
import type { Module } from './core-modules';
|
||||
import type { Result } from 'ts-results-es';
|
||||
|
||||
@@ -17,11 +16,10 @@ export interface SernEventsMapping {
|
||||
}
|
||||
|
||||
export type Payload =
|
||||
| { type: PayloadType.Success; module: Module }
|
||||
| { type: PayloadType.Failure; module?: Module; reason: string | Error }
|
||||
| { type: PayloadType.Warning; module: undefined; reason: string };
|
||||
| { type: 'success'; module: Module }
|
||||
| { type: 'failure'; module?: Module; reason: string | Error }
|
||||
| { type: 'warning'; module: undefined; reason: string };
|
||||
|
||||
//https://github.com/molszanski/iti/blob/0a3a006113b4176316c308805314a135c0f47902/iti/src/_utils.ts#L29C1-L29C76
|
||||
export type UnpackFunction<T> = T extends (...args: any) => infer U ? U : T
|
||||
export type UnpackedDependencies = {
|
||||
[K in keyof Dependencies]: UnpackFunction<Dependencies[K]>
|
||||
|
||||
Reference in New Issue
Block a user