mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
documentation
This commit is contained in:
@@ -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<const T extends keyof Dependencies>(key: T) {
|
||||
return $Service(key) as Dependencies[T]
|
||||
@@ -92,7 +92,9 @@ export function Service<const T extends keyof Dependencies>(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<const T extends (keyof Dependencies)[]>(...keys: [...T]) {
|
||||
return $Services<T, IntoDependencies<T>>(...keys)
|
||||
|
||||
@@ -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<T extends keyof ClientEvents>(mod: {
|
||||
name: T;
|
||||
once?: boolean;
|
||||
execute: (...args: ClientEvents[T]) => Awaitable<unknown>;
|
||||
}) {
|
||||
return eventModule({ type: EventType.Discord, ...mod, });
|
||||
}
|
||||
|
||||
export function scheduledTask(ism: ScheduledTask) {
|
||||
return ism
|
||||
}
|
||||
export function scheduledTask(ism: ScheduledTask) { return ism }
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user