refactor: apiInit Refactor

This commit is contained in:
手瓜一十雪
2024-11-14 10:52:03 +08:00
parent e8bf6fa0a6
commit c893ec6030
4 changed files with 21 additions and 13 deletions

View File

@@ -120,7 +120,13 @@ export class NapCatCore {
if (!fs.existsSync(this.NapCatTempPath)) {
fs.mkdirSync(this.NapCatTempPath, { recursive: true });
}
//遍历this.apis[i].initApi 如果存在该函数进行async 调用
for (const apiKey in this.apis) {
const api = this.apis[apiKey as keyof StableNTApiWrapper];
if ('initApi' in api && typeof api.initApi === 'function') {
await api.initApi();
}
}
this.initNapCatCoreListeners().then().catch(this.context.logger.logError.bind(this.context.logger));
this.context.logger.setFileLogEnabled(