reciple 6.0.0-dev.7 → 6.0.0-dev.8

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/cjs/bin.js CHANGED
@@ -36,11 +36,11 @@ if (!client.isClientLogsSilent)
36
36
  client.addCommandListeners();
37
37
  await client.modules.startModules(await client.modules.getModulesFromFiles({
38
38
  files: await client.modules.getModuleFiles(),
39
- }), true, true);
39
+ }));
40
40
  client.on('ready', async () => {
41
- await client.modules.loadModules(client.modules.modules.toJSON());
41
+ await client.modules.loadModules(client.modules.modules.toJSON(), true);
42
42
  if (client.config.commands.slashCommand.registerCommands)
43
- client.commands.registerApplicationCommands();
43
+ await client.commands.registerApplicationCommands();
44
44
  if (!client.isClientLogsSilent)
45
45
  client.logger.warn(`Logged in as ${client.user?.tag || 'Unknown'}!`);
46
46
  client.on('cacheSweep', () => client.cooldowns.clean());
@@ -19,18 +19,18 @@ class RecipleModule {
19
19
  get displayName() {
20
20
  return this.filePath ?? this.id;
21
21
  }
22
- async start(resolveCommands = true) {
23
- if (resolveCommands)
24
- this.resolveCommands();
22
+ async start() {
25
23
  return Promise.resolve(this.script.onStart(this.client));
26
24
  }
27
- async load() {
25
+ async load(resolveCommands = true) {
28
26
  if (typeof this.script.onLoad === 'function')
29
- this.script.onLoad(this.client);
27
+ await this.script.onLoad(this.client);
28
+ if (resolveCommands)
29
+ this.resolveCommands();
30
30
  }
31
31
  async unLoad(reason) {
32
32
  if (typeof this.script.onUnLoad === 'function')
33
- this.script.onUnLoad(reason, this.client);
33
+ await this.script.onUnLoad(reason, this.client);
34
34
  }
35
35
  async registerSlashCommands(...guilds) {
36
36
  for (const command of this.commands.toJSON()) {
@@ -40,13 +40,13 @@ class ClientModuleManager {
40
40
  this.client = options.client;
41
41
  options.modules?.forEach(m => (m instanceof RecipleModule_1.RecipleModule ? m : new RecipleModule_1.RecipleModule({ client: this.client, script: m })));
42
42
  }
43
- async startModules(modules, addModuleCommandsToClient = true, ignoreErrors = true) {
43
+ async startModules(modules, ignoreErrors = true) {
44
44
  for (const module_ of modules) {
45
45
  if (!this.client.isClientLogsSilent)
46
46
  this.client.logger.log(`Starting module '${module_}'`);
47
47
  try {
48
48
  let error;
49
- const start = await module_.start(true).catch(err => {
49
+ const start = await module_.start().catch(err => {
50
50
  error = err;
51
51
  return false;
52
52
  });
@@ -58,9 +58,6 @@ class ClientModuleManager {
58
58
  continue;
59
59
  }
60
60
  this.modules.set(module_.id, module_);
61
- if (addModuleCommandsToClient) {
62
- this.client.commands.add(module_.commands.toJSON());
63
- }
64
61
  }
65
62
  catch (err) {
66
63
  if (!ignoreErrors)
@@ -71,7 +68,7 @@ class ClientModuleManager {
71
68
  }
72
69
  return modules;
73
70
  }
74
- async loadModules(modules, ignoreErrors = true) {
71
+ async loadModules(modules, addModuleCommandsToClient = true, ignoreErrors = true) {
75
72
  for (const module_ of this.modules.toJSON()) {
76
73
  try {
77
74
  await module_.load().catch(err => {
@@ -79,6 +76,9 @@ class ClientModuleManager {
79
76
  });
80
77
  if (!this.client.isClientLogsSilent)
81
78
  this.client.logger.log(`Loaded module '${module_}'`);
79
+ if (addModuleCommandsToClient) {
80
+ this.client.commands.add(module_.commands.toJSON());
81
+ }
82
82
  }
83
83
  catch (err) {
84
84
  if (!ignoreErrors)
@@ -45,8 +45,8 @@ export declare class RecipleModule<M = unknown> {
45
45
  metadata?: M;
46
46
  get displayName(): string;
47
47
  constructor(options: RecipleModuleOptions<M>);
48
- start(resolveCommands?: boolean): Promise<boolean>;
49
- load(): Promise<void>;
48
+ start(): Promise<boolean>;
49
+ load(resolveCommands?: boolean): Promise<void>;
50
50
  unLoad(reason?: any): Promise<void>;
51
51
  registerSlashCommands(...guilds: RestOrArray<GuildResolvable>): Promise<void>;
52
52
  unregisterSlashCommands(...guilds: RestOrArray<GuildResolvable>): Promise<void>;
@@ -10,8 +10,8 @@ export declare class ClientModuleManager {
10
10
  readonly client: RecipleClient;
11
11
  readonly modules: Collection<string, RecipleModule>;
12
12
  constructor(options: ClientModuleManagerOptions);
13
- startModules(modules: RecipleModule[], addModuleCommandsToClient?: boolean, ignoreErrors?: boolean): Promise<RecipleModule[]>;
14
- loadModules(modules: RecipleModule[], ignoreErrors?: boolean): Promise<RecipleModule[]>;
13
+ startModules(modules: RecipleModule[], ignoreErrors?: boolean): Promise<RecipleModule[]>;
14
+ loadModules(modules: RecipleModule[], addModuleCommandsToClient?: boolean, ignoreErrors?: boolean): Promise<RecipleModule[]>;
15
15
  unLoadModules(modules: RecipleModule[], removeUnloadedModules?: boolean, ignoreErrors?: boolean): Promise<RecipleModule[]>;
16
16
  getModulesFromFiles(options: ClientModuleManagerGetModulesFromFilesOptions): Promise<RecipleModule[]>;
17
17
  static validateScript(script: unknown): script is RecipleScript;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "6.0.0-dev.7",
3
+ "version": "6.0.0-dev.8",
4
4
  "bin": "./dist/cjs/bin.js",
5
5
  "license": "GPL-3.0",
6
6
  "main": "./dist/cjs/index.js",