bakit 2.0.0-alpha.14 → 2.0.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +16 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -321,6 +321,7 @@ declare class CommandManager extends BaseClientManager {
|
|
|
321
321
|
* @returns The command object if unloaded successfully.
|
|
322
322
|
*/
|
|
323
323
|
unload(path: string): Promise<Command | undefined>;
|
|
324
|
+
reload(path: string): Promise<Command<any[]> | undefined>;
|
|
324
325
|
/**
|
|
325
326
|
* Add a command to the registry.
|
|
326
327
|
* @param command Command to add.
|
|
@@ -373,6 +374,7 @@ declare class ListenerManager extends BaseClientManager {
|
|
|
373
374
|
* @returns The listener object if unloaded successfully.
|
|
374
375
|
*/
|
|
375
376
|
unload(path: string): Promise<Listener | undefined>;
|
|
377
|
+
reload(path: string): Promise<Listener<keyof BakitClientEvents> | undefined>;
|
|
376
378
|
/**
|
|
377
379
|
* Add a listener to the registry and create a listener for client.
|
|
378
380
|
* @param listener Listener to add.
|
package/dist/index.js
CHANGED
|
@@ -590,7 +590,7 @@ var CommandManager = class extends BaseClientManager {
|
|
|
590
590
|
entries = new Collection();
|
|
591
591
|
async loadModules(entryDir) {
|
|
592
592
|
let pattern = posix.join(posix.resolve(entryDir), "commands", "**/*.{ts,js}"), files = await glob(pattern, { cwd: process.cwd() }), filtered = (await Promise.all(files.map((file) => this.load(file)))).filter((c) => !!c);
|
|
593
|
-
return console.log(`[Loader] Loaded ${filtered.length}/${files.length}`), filtered;
|
|
593
|
+
return console.log(`[Loader] Loaded ${filtered.length}/${files.length} command(s)`), filtered;
|
|
594
594
|
}
|
|
595
595
|
/**
|
|
596
596
|
* Load the file and add the command to the registry.
|
|
@@ -619,6 +619,12 @@ var CommandManager = class extends BaseClientManager {
|
|
|
619
619
|
if (Module.isLoaded(path2) && (command ??= await Module.import(path2, true), Module.unload(path2)), this.entries.delete(path2), !!command)
|
|
620
620
|
return this.remove(command);
|
|
621
621
|
}
|
|
622
|
+
async reload(path2) {
|
|
623
|
+
await this.unload(path2);
|
|
624
|
+
let command = await this.load(path2);
|
|
625
|
+
if (command)
|
|
626
|
+
return console.log(`[Loader] Reloaded command'${command.options.name}' at '${path2}'`), command;
|
|
627
|
+
}
|
|
622
628
|
/**
|
|
623
629
|
* Add a command to the registry.
|
|
624
630
|
* @param command Command to add.
|
|
@@ -673,7 +679,7 @@ var ListenerManager = class extends BaseClientManager {
|
|
|
673
679
|
executors = /* @__PURE__ */ new WeakMap();
|
|
674
680
|
async loadModules(entryDir) {
|
|
675
681
|
let pattern = posix.join(posix.resolve(entryDir), "listeners", "**/*.{ts,js}"), files = await glob(pattern, { cwd: process.cwd() }), filtered = (await Promise.all(files.map((file) => this.load(file)))).filter((l) => !!l);
|
|
676
|
-
return console.log(`[Loader] Loaded ${filtered.length}/${files.length}`), filtered;
|
|
682
|
+
return console.log(`[Loader] Loaded ${filtered.length}/${files.length} listener(s)`), filtered;
|
|
677
683
|
}
|
|
678
684
|
/**
|
|
679
685
|
* Load the file and add the listener to the registry.
|
|
@@ -702,6 +708,12 @@ var ListenerManager = class extends BaseClientManager {
|
|
|
702
708
|
if (Module.isLoaded(path2) && (listener ??= await Module.import(path2, true), Module.unload(path2)), this.entries.delete(path2), !!listener)
|
|
703
709
|
return this.remove(listener)?.[0];
|
|
704
710
|
}
|
|
711
|
+
async reload(path2) {
|
|
712
|
+
await this.unload(path2);
|
|
713
|
+
let listener = await this.load(path2);
|
|
714
|
+
if (listener)
|
|
715
|
+
return console.log(`[Loader] Reloaded listener '${listener.options.name}' at '${path2}'`), listener;
|
|
716
|
+
}
|
|
705
717
|
/**
|
|
706
718
|
* Add a listener to the registry and create a listener for client.
|
|
707
719
|
* @param listener Listener to add.
|
|
@@ -989,10 +1001,10 @@ var Instance = class {
|
|
|
989
1001
|
let target = type.split(":")[1], { listeners, commands } = this.client.managers;
|
|
990
1002
|
switch (target) {
|
|
991
1003
|
case "listeners":
|
|
992
|
-
|
|
1004
|
+
await listeners.reload(file);
|
|
993
1005
|
break;
|
|
994
1006
|
case "commands":
|
|
995
|
-
|
|
1007
|
+
await commands.reload(file);
|
|
996
1008
|
break;
|
|
997
1009
|
}
|
|
998
1010
|
}
|