Module#aiをゲッターに

This commit is contained in:
takejohn 2024-03-25 23:45:20 +09:00
parent 1ca93c4edf
commit 1c842a4b95

View file

@ -4,11 +4,11 @@ import 藍, { InstallerResult } from '@/ai.js';
export default abstract class Module { export default abstract class Module {
public abstract readonly name: string; public abstract readonly name: string;
protected ai: ; private maybeAi?: ;
private doc: any; private doc: any;
public init(ai: ) { public init(ai: ) {
this.ai = ai; this.maybeAi = ai;
this.doc = this.ai.moduleData.findOne({ this.doc = this.ai.moduleData.findOne({
module: this.name module: this.name
@ -24,6 +24,13 @@ export default abstract class Module {
public abstract install(): InstallerResult; public abstract install(): InstallerResult;
protected get ai(): {
if (this.maybeAi == null) {
throw new TypeError('This module has not been initialized');
}
return this.maybeAi;
}
@bindThis @bindThis
protected log(msg: string) { protected log(msg: string) {
this.ai.log(`[${this.name}]: ${msg}`); this.ai.log(`[${this.name}]: ${msg}`);