load order

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

View File

@ -37,14 +37,7 @@ class BaseClient extends EventEmitter {
async build() {
const 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`);
let start = Date.now();
// 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;
@ -55,9 +48,20 @@ class BaseClient extends EventEmitter {
const { default: APIManager } = API;
this.api = new APIManager(this, this._options.api);
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.readyAt = Date.now();