sheweny
Version:
The powerful framework for create discord bots
74 lines • 2.53 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SelectMenu = void 0;
const index_js_1 = require("./index.js");
const index_js_2 = require("../helpers/index.js");
/**
* Represents an Select Menu structure
* @extends {BaseStructure}
*/
class SelectMenu extends index_js_1.BaseStructure {
/**
* Constructor for build a Select Menu
* @param {ShewenyClient} [client] Client framework
* @param {CustomId} [customId] Custom id for one or more select menus
* @param {SelectMenuData | undefined} [options] The options of the select menu
*/
constructor(client, customId, options) {
super(client, options?.enabled);
/**
* Cooldown of a button in seconds
* @type {number}
*/
Object.defineProperty(this, "cooldown", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
/**
* Custom id for one or more select menus
* @type {CustomId}
*/
Object.defineProperty(this, "customId", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.cooldown = (options?.cooldown || client.managers.buttons?.default?.cooldown) ?? 0;
this.customId = customId;
}
/**
* Register a select menu in collections
* @returns {Collection<string[]| RegExp[], SelectMenu | ShewenyError>} The select menus collection
*/
async register() {
if (!this.path)
return new index_js_2.ShewenyError(this.client, 'PATH_NOT_DEFINE', 'SelectMenu', this.customId.toString());
const SelectMenuImported = (await Promise.resolve().then(() => __importStar(require(this.path)))).default;
const sm = new SelectMenuImported(this.client);
return sm;
}
/**
* Reload a select menu
* @returns {Promise<Collection<string[]| RegExp[], SelectMenu> | ShewenyError>} The select menus collection
*/
async reload() {
this.unregister();
return this.register();
}
/**
* Unregister a select menu from collections
* @returns {boolean}
*/
unregister() {
this.client.collections.selectMenus?.delete(this.customId);
if (!this.path)
return false;
delete require.cache[require.resolve(this.path)];
return true;
}
}
exports.SelectMenu = SelectMenu;
//# sourceMappingURL=SelectMenu.js.map