diff --git a/src/core/ioc.ts b/src/core/ioc.ts index 32bb56d..a605a88 100644 --- a/src/core/ioc.ts +++ b/src/core/ioc.ts @@ -74,9 +74,9 @@ export async function makeDependencies (conf: ValidDependencyConfig) { /** - * The new Service api, a cleaner alternative to useContainer + * The Service api, which allows users to access dependencies in places IOC cannot reach. * To obtain intellisense, ensure a .d.ts file exists in the root of compilation. - * Usually our scaffolding tool takes care of this. + * Our scaffolding tool takes care of this. * Note: this method only works AFTER your container has been initiated * @since 3.0.0 * @example @@ -84,7 +84,7 @@ export async function makeDependencies (conf: ValidDependencyConfig) { * const client = Service('@sern/client'); * ``` * @param key a key that corresponds to a dependency registered. - * + * @throws if container is absent or not present */ export function Service(key: T) { return $Service(key) as Dependencies[T] @@ -92,7 +92,9 @@ export function Service(key: T) { /** * @since 3.0.0 * The plural version of {@link Service} + * @throws if container is absent or not present * @returns array of dependencies, in the same order of keys provided + * */ export function Services(...keys: [...T]) { return $Services>(...keys) diff --git a/src/core/modules.ts b/src/core/modules.ts index 24c34d8..4de590a 100644 --- a/src/core/modules.ts +++ b/src/core/modules.ts @@ -37,17 +37,15 @@ export function eventModule(mod: InputEvent): Module { /** Create event modules from discord.js client events, * This is an {@link eventModule} for discord events, * where typings can be very bad. - * @Experimental * @param mod */ export function discordEvent(mod: { name: T; + once?: boolean; execute: (...args: ClientEvents[T]) => Awaitable; }) { return eventModule({ type: EventType.Discord, ...mod, }); } -export function scheduledTask(ism: ScheduledTask) { - return ism -} +export function scheduledTask(ism: ScheduledTask) { return ism } diff --git a/src/core/structures/default-services.ts b/src/core/structures/default-services.ts index 4c7cf27..2700f1c 100644 --- a/src/core/structures/default-services.ts +++ b/src/core/structures/default-services.ts @@ -54,7 +54,8 @@ export class TaskScheduler implements Disposable { try { const onTick = async function(this: CronJob) { task.execute({ - deps, id: uuid, + deps, + id: uuid, lastTimeExecution: this.lastExecution, nextTimeExecution: this.nextDate().toJSDate() }) @@ -82,10 +83,10 @@ export class TaskScheduler implements Disposable { } dispose() { - for(const [id,] of this.__tasks){ + this.__tasks.forEach((_, id) => { this.kill(id); this.__tasks.delete(id); - } + }) } } diff --git a/src/handlers/tasks.ts b/src/handlers/tasks.ts index cf01605..a204fc5 100644 --- a/src/handlers/tasks.ts +++ b/src/handlers/tasks.ts @@ -1,7 +1,6 @@ import * as Files from '../core/module-loading' import { UnpackedDependencies } from "../types/utility"; import type { ScheduledTask } from "../types/core-modules"; -import { CronJob } from "cron"; import { relative } from "path"; import { fileURLToPath } from "url";