add option to disable api loading

This commit is contained in:
Erik 2022-04-22 18:12:06 +03:00
parent c5d2b292aa
commit c15530dc90
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
2 changed files with 5 additions and 2 deletions

View File

@ -46,6 +46,7 @@
} }
}, },
"api": { "api": {
"load": false,
"http": { "http": {
"port": 5000 "port": 5000
}, },

View File

@ -37,8 +37,10 @@ class BaseClient extends EventEmitter {
process.exit(); // Prevent a boot loop when shards die due to an error in the client process.exit(); // Prevent a boot loop when shards die due to an error in the client
}); });
const API = await import('/Documents/My programs/GBot/api/index.js') this.logger.status('Shards spawned');
.catch(() => this.logger.warn(`Error importing API files, continuing without`));
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;
// const API = await import('./api/index.js').catch(() => this.logger.warn(`Error importing API files, continuing without`)); // const API = await import('./api/index.js').catch(() => this.logger.warn(`Error importing API files, continuing without`));
if (API) { if (API) {
this.logger.info('Booting up API'); this.logger.info('Booting up API');