UNPKG

djs-menu-v13

Version:

A module for create simple and complex menu for your Discord Bot

107 lines (106 loc) 4.22 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.MenuSelectPage = void 0; var generateRandomId_1 = __importDefault(require("../Util/generateRandomId")); var MenuSelectPage = (function () { function MenuSelectPage() { this.id = ''; this.placeholder = ''; this.files = []; this.options = []; this.content = ''; this.timeout = 6000; this.type = 'MenuSelectPage'; this.embeds = []; } MenuSelectPage.prototype.setId = function (id) { if (!id) throw new Error('The ID of the page can not be empty.'); this.id = id; return this; }; MenuSelectPage.prototype.setPlaceholder = function (placeholder) { if (!placeholder) throw new Error('The placeholder of the page can not be empty.'); this.placeholder = placeholder; return this; }; MenuSelectPage.prototype.addEmbed = function (embed) { if (!embed) throw new Error('The embed can not be empty.'); this.embeds.push(embed); return this; }; MenuSelectPage.prototype.addOptions = function (options) { var _this = this; if (!options) throw new Error('Options can not be empty.'); options.forEach(function (option) { if (typeof option.target === 'function') { _this.options.push({ label: option.label, target: option.target, value: (0, generateRandomId_1.default)() + "." + _this.id, description: option === null || option === void 0 ? void 0 : option.description, emoji: option === null || option === void 0 ? void 0 : option.emoji, }); } else { _this.options.push({ label: option.label, target: option.target, value: (0, generateRandomId_1.default)() + "." + _this.id, description: option === null || option === void 0 ? void 0 : option.description, emoji: option === null || option === void 0 ? void 0 : option.emoji, }); } }); return this; }; MenuSelectPage.prototype.addOption = function (option) { if (!option) throw new Error('Option can not be empty.'); if (typeof option.target === 'function') { this.options.push({ label: option.label, target: option.target, value: (0, generateRandomId_1.default)() + "." + this.id, description: option === null || option === void 0 ? void 0 : option.description, emoji: option === null || option === void 0 ? void 0 : option.emoji, }); } else { this.options.push({ label: option.label, target: option.target, value: (0, generateRandomId_1.default)() + "." + this.id, description: option === null || option === void 0 ? void 0 : option.description, emoji: option === null || option === void 0 ? void 0 : option.emoji, }); } return this; }; MenuSelectPage.prototype.setContent = function (content) { if (!content) throw new Error('Content cannot be empty'); this.content = content; return this; }; MenuSelectPage.prototype.setTimeout = function (timeout) { if (!timeout) throw new Error('Timeout can not be empty.'); this.timeout = timeout; return this; }; MenuSelectPage.prototype.addFile = function (file) { if (!file) throw new Error('File can not be empty.'); this.files.push(file); return this; }; return MenuSelectPage; }()); exports.MenuSelectPage = MenuSelectPage;