···23The command loader walks a directory and stores data from any file exporting an object that follows the Command type structure.
2425## Handlers
26-Handlers are static classes, which receive exported data from Loaders, though not directly, as Loader data is usually fetched by a Registry, and the Registry invokes a Handler to get data into our queue system, more on that later.
2728-Each handler has an `invoke` method, which takes JSON data, though it must always use the common exported JSON structure provided by Loaders.
2930-Any data filtering or mapping is then run in the background by the invoked Handler, which ultimately pushes data to the queue, and triggers a "handler::postInvoke" event afterward.
003132@Todo: document Handler lifecycle events
33
···23The command loader walks a directory and stores data from any file exporting an object that follows the Command type structure.
2425## Handlers
26+Handlers are static classes, which are invoked, usually on discord events or interactions.
2728+Each handler has an `invoke` method, which is the one I mentioned calling above.
2930+The handler then queries the core registry and all other registries afterward, to find a fitting execution target.
31+32+It's important to note that only repositories marked as active are taken into account.
3334@Todo: document Handler lifecycle events
35
···23 * Recursively collects data from a directory based on the path specificed in dataSource property.
24 */
25 public async collect() {
26- const glob = new Glob(`**.ts`);
27 const iterator = glob.scan(this.dataSource);
2829 for await (const path of iterator) {
···23 * Recursively collects data from a directory based on the path specificed in dataSource property.
24 */
25 public async collect() {
26+ const glob = new Glob(`**/**.ts`);
27 const iterator = glob.scan(this.dataSource);
2829 for await (const path of iterator) {
+12-2
src/core/Registry.ts
···1-import type { Module } from "../loaders/ModuleLoader"
23export interface IRegistry {
04 store: Module[]
56 collect: () => Promise<void>
···10}
1112export class Registry implements IRegistry {
013 public store: Module[] = [];
1415- public async collect() { }
000000001617 public async prepare() { }
18
···1+import { ModuleLoader, type Module } from "../loaders/ModuleLoader"
23export interface IRegistry {
4+ dataSource: string
5 store: Module[]
67 collect: () => Promise<void>
···11}
1213export class Registry implements IRegistry {
14+ public dataSource: string;
15 public store: Module[] = [];
1617+ public constructor(dataSource: string) {
18+ this.dataSource = dataSource;
19+ }
20+21+ // @Todo: finish this implementation
22+ public async collect() {
23+ const moduleLoader = await (new ModuleLoader(this.dataSource)).collect();
24+ console.log(moduleLoader.getJSON()[0]?.exports);
25+ }
2627 public async prepare() { }
28
+3-1
src/core/VoidyClient.ts
···7 public constructor(options: ClientOptions) {
8 super(options);
910- this.registries = [new Registry()];
0011 }
1213 public start(token: string) {
···7 public constructor(options: ClientOptions) {
8 super(options);
910+ this.registries = [
11+ new Registry(`${process.cwd()}/src/modules`),
12+ ];
13 }
1415 public start(token: string) {