From 3d10634bcdb5649a81796f4c3877cc6f078ba793 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 15 Jan 2019 10:23:54 +0900 Subject: [PATCH] :v: --- src/ai.ts | 6 +++--- src/index.ts | 34 +++++++++++++++++----------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/ai.ts b/src/ai.ts index 6188d9d..4f1d3d2 100644 --- a/src/ai.ts +++ b/src/ai.ts @@ -46,7 +46,7 @@ export default class 藍 { public friends: loki.Collection; - constructor(account: User, ready?: Function) { + constructor(account: User, ready: (run: Function) => void) { this.account = account; this.db = new loki('memory.json', { @@ -57,7 +57,7 @@ export default class 藍 { if (err) { this.log(chalk.red(`Failed to load DB: ${err}`)); } else { - if (ready) ready(); + ready(this.run); } } }); @@ -69,7 +69,7 @@ export default class 藍 { } @autobind - public run() { + private run() { //#region Init DB this.contexts = getCollection(this.db, 'contexts', { indices: ['key'] diff --git a/src/index.ts b/src/index.ts index 1fbaabf..4cea891 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,24 +40,24 @@ promiseRetry(retry => { log('Starting AiOS...'); - const ai = new 藍(account); + const ai = new 藍(account, run => { + new EmojiModule(ai); + new FortuneModule(ai); + new GuessingGameModule(ai); + new ReversiModule(ai); + new TimerModule(ai); + new DiceModule(ai); + new CoreModule(ai); + new PingModule(ai); + new WelcomeModule(ai); + new ServerModule(ai); + new FollowModule(ai); + new BirthdayModule(ai); + new ValentineModule(ai); + if (config.keywordEnabled) new KeywordModule(ai); - new EmojiModule(ai); - new FortuneModule(ai); - new GuessingGameModule(ai); - new ReversiModule(ai); - new TimerModule(ai); - new DiceModule(ai); - new CoreModule(ai); - new PingModule(ai); - new WelcomeModule(ai); - new ServerModule(ai); - new FollowModule(ai); - new BirthdayModule(ai); - new ValentineModule(ai); - if (config.keywordEnabled) new KeywordModule(ai); - - ai.run(); + run(); + }); }).catch(e => { log(chalk.red('Failed to fetch the account')); });