diff --git a/src/core/ioc/base.ts b/src/core/ioc/base.ts index 2fe45ff..b632ba6 100644 --- a/src/core/ioc/base.ts +++ b/src/core/ioc/base.ts @@ -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(); } diff --git a/src/index.ts b/src/index.ts index a9a9f1f..6baefda 100644 --- a/src/index.ts +++ b/src/index.ts @@ -89,3 +89,4 @@ export async function Asset(p: string, opts?: { name?: string, encoding: AssetEn return fs.readFile(filePath, encoding); } } + diff --git a/src/sern.ts b/src/sern.ts index 5ea5b1e..3cd067d 100644 --- a/src/sern.ts +++ b/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; - } - } -} diff --git a/src/types/core-plugin.ts b/src/types/core-plugin.ts index bd01f59..89f8a12 100644 --- a/src/types/core-plugin.ts +++ b/src/types/core-plugin.ts @@ -38,20 +38,17 @@ export interface InitArgs = Processed> { module: T; absPath: string; deps: Dependencies - updateModule: (module: Partial) => T } export interface Plugin { type: PluginType; execute: (...args: Args) => PluginResult; } -export interface InitPlugin { +export interface InitPlugin extends Plugin { type: PluginType.Init; - execute: (...args: Args) => PluginResult; } -export interface ControlPlugin { +export interface ControlPlugin extends Plugin { type: PluginType.Control; - execute: (...args: Args) => PluginResult; } export type AnyPlugin = ControlPlugin | InitPlugin<[InitArgs>]>; diff --git a/src/types/utility.ts b/src/types/utility.ts index 64c95da..dcbe3b2 100644 --- a/src/types/utility.ts +++ b/src/types/utility.ts @@ -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 extends (...args: any) => infer U ? U : T export type UnpackedDependencies = { [K in keyof Dependencies]: UnpackFunction