sheweny
Version:
The powerful framework for create discord bots
68 lines • 2.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ButtonsManager = void 0;
const Loader_js_1 = require("../utils/Loader.js");
const index_js_1 = require("../helpers/index.js");
const index_js_2 = require("./index.js");
const index_js_3 = require("../structures/index.js");
const discord_js_1 = require("discord.js");
/**
* Manager for Buttons
*/
class ButtonsManager extends index_js_2.BaseManager {
/**
* Constructor of buttons manager
* @param {ShewenyClient} client Client framework
* @param {ButtonsManagerOptions} options The options of the manager
*/
constructor(client, options) {
super(client, options);
/**
* Collection of the buttons
* @type {Collection<CustomId, Button[]> | undefined}
*/
Object.defineProperty(this, "buttons", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
/**
* Default data for the buttons
* @type {ButtonsManagerDefaultOptions}
*/
Object.defineProperty(this, "default", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.default = {
cooldown: options.default?.cooldown || 0,
};
}
/**
* Load all buttons in collection
* @returns {Promise<Collection<CustomId, Button[]> | undefined> }
*/
async loadAll() {
const loader = new Loader_js_1.Loader(this.client, this.directory, 'customId', {
asyncRead: this.asyncRead,
manager: this,
instance: index_js_3.Button,
});
this.buttons = await loader.load();
new index_js_1.ShewenyInformation(this.client, `- Buttons loaded : ${this.buttons.size}`);
return this.buttons;
}
/**
* Unload all buttons
* @returns {void}
*/
unloadAll() {
this.buttons = new discord_js_1.Collection();
this.client.collections.buttons.clear();
}
}
exports.ButtonsManager = ButtonsManager;
//# sourceMappingURL=ButtonsManager.js.map