UNPKG

sheweny

Version:

The powerful framework for create discord bots

86 lines 2.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Inhibitor = void 0; const index_js_1 = require("./index.js"); const index_js_2 = require("../helpers/index.js"); /** * Represents an Command structure * @extends {BaseStructure} */ class Inhibitor extends index_js_1.BaseStructure { /** * Constructor for build a Inhibitor * @param {ShewenyClient} [client] Client framework * @param {string} [name] Name of the event * @param {InhibitorData | undefined} [options] Options of the inhibitor */ constructor(client, name, options) { super(client, options?.enabled); /** * Name of a inhibitor * @type {string} */ Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: void 0 }); /** * Priority of a inhibitor * @type {number} */ Object.defineProperty(this, "priority", { enumerable: true, configurable: true, writable: true, value: void 0 }); /** * Type(s) of a inhibitor * @type {InhibitorType[]} */ Object.defineProperty(this, "type", { enumerable: true, configurable: true, writable: true, value: void 0 }); const defaultData = client.managers.inhibitors?.default || {}; this.name = name; this.priority = (options?.priority || defaultData.priority) ?? 0; this.type = (options?.type || defaultData.type) ?? []; } /** * Register an inhibitor in collections * @returns {Promise<Inhibitor | ShewenyError>} The loaded inhibitor */ async register() { if (!this.path) return new index_js_2.ShewenyError(this.client, 'PATH_NOT_DEFINE', 'Inhibitor', this.name); const InhibitorImported = (await Promise.resolve().then(() => __importStar(require(this.path)))).default; const inhib = new InhibitorImported(this.client); return inhib; } /** * Reload the inhibitor * @returns {Promise<Inhibitor | ShewenyError>} The loaded inhibitor */ async reload() { this.unregister(); return this.register(); } /** * Unregister the inhibitor from cache * @returns {boolean} */ unregister() { this.client.collections.inhibitors?.delete(this.name); if (!this.path) return false; delete require.cache[require.resolve(this.path)]; return true; } } exports.Inhibitor = Inhibitor; //# sourceMappingURL=Inhibitor.js.map