"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PluginBase = void 0;
class PluginBase {
    context;
    active = true;
    constructor(context = {}) {
        this.context = context;
    }
    enable() {
        this.active = true;
    }
    disable() {
        this.active = false;
    }
    isEnabled() {
        if (!this.active)
            return false;
        const envOk = this.hasRequiredEnv();
        const extraOk = this.customEnableCheck();
        const enabled = envOk && extraOk;
        return enabled;
    }
    hasRequiredEnv() {
        const isGood = !this.meta.requires ||
            this.meta.requires.every((k) => process.env[k] && process.env[k] !== "");
        return isGood;
    }
    customEnableCheck() {
        return true;
    }
    log(message, level = "info") {
        if (this.context.Events) {
            this.context.Events.log(this.meta.name, message, level);
        }
        else {
            if (level === "error")
                console.error(`[${this.meta.name}] ${message}`);
            else if (level === "warn")
                console.warn(`[${this.meta.name}] ${message}`);
            else
                console.log(`[${this.meta.name}] ${message}`);
        }
    }
    async callMany(input) {
        return this.call(input);
    }
}
exports.PluginBase = PluginBase;
//# sourceMappingURL=PluginBase.js.map