From 1c842a4b95328e75b646b225bfa0112380bf6e4c Mon Sep 17 00:00:00 2001 From: takejohn <105504345+takejohn@users.noreply.github.com> Date: Mon, 25 Mar 2024 23:45:20 +0900 Subject: [PATCH] =?UTF-8?q?Module#ai=E3=82=92=E3=82=B2=E3=83=83=E3=82=BF?= =?UTF-8?q?=E3=83=BC=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/module.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/module.ts b/src/module.ts index 27bcf65..6d4770e 100644 --- a/src/module.ts +++ b/src/module.ts @@ -4,11 +4,11 @@ import 藍, { InstallerResult } from '@/ai.js'; export default abstract class Module { public abstract readonly name: string; - protected ai: 藍; + private maybeAi?: 藍; private doc: any; public init(ai: 藍) { - this.ai = ai; + this.maybeAi = ai; this.doc = this.ai.moduleData.findOne({ module: this.name @@ -24,6 +24,13 @@ export default abstract class Module { public abstract install(): InstallerResult; + protected get ai(): 藍 { + if (this.maybeAi == null) { + throw new TypeError('This module has not been initialized'); + } + return this.maybeAi; + } + @bindThis protected log(msg: string) { this.ai.log(`[${this.name}]: ${msg}`);