load order

This commit is contained in:
Erik 2022-07-23 21:15:25 +03:00
parent a85d0ae0d2
commit 1106d892e3
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -37,14 +37,7 @@ class BaseClient extends EventEmitter {
async build() { async build() {
const start = Date.now(); let start = Date.now();
await this.shardingManager.spawn().catch((error) => {
this.logger.error(`Fatal error during shard spawning:\n${error.stack || error}`);
// eslint-disable-next-line no-process-exit
process.exit(); // Prevent a boot loop when shards die due to an error in the client
});
this.logger.status(`Shards spawned, spawned ${this.shardingManager.shards.size} shards. Took ${Date.now() - start} ms`);
// const API = this._options.api.load ? await import('/Documents/My programs/GBot/api/index.js') // const API = this._options.api.load ? await import('/Documents/My programs/GBot/api/index.js')
// .catch(() => this.logger.warn(`Error importing API files, continuing without`)) : null; // .catch(() => this.logger.warn(`Error importing API files, continuing without`)) : null;
@ -55,9 +48,20 @@ class BaseClient extends EventEmitter {
const { default: APIManager } = API; const { default: APIManager } = API;
this.api = new APIManager(this, this._options.api); this.api = new APIManager(this, this._options.api);
await this.api.init(); await this.api.init();
this.logger.info('API ready.'); const now = Date.now();
this.logger.info(`API ready. Took ${now - start} ms`);
start = now;
} }
this.logger.status(`Starting bot shards`);
await this.shardingManager.spawn().catch((error) => {
this.logger.error(`Fatal error during shard spawning:\n${error.stack || error}`);
// eslint-disable-next-line no-process-exit
process.exit(); // Prevent a boot loop when shards die due to an error in the client
});
this.logger.status(`Shards spawned, spawned ${this.shardingManager.shards.size} shards. Took ${Date.now() - start} ms`);
this._built = true; this._built = true;
this.readyAt = Date.now(); this.readyAt = Date.now();