UNPKG

seyfert

Version:

The most advanced framework for discord bots

79 lines (78 loc) 2.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Button = void 0; const common_1 = require("../common"); const types_1 = require("../types"); const Base_1 = require("./Base"); /** * Represents a button component. * @template Type - The type of the button component. */ class Button extends Base_1.BaseComponentBuilder { constructor(data = {}) { super({ type: types_1.ComponentType.Button, ...data }); } /** * Sets the custom ID for the button. * @param id - The custom ID to set. * @returns The modified Button instance. */ setCustomId(id) { this.data.custom_id = id; return this; } /** * Sets the URL for the button. * @param url - The URL to set. * @returns The modified Button instance. */ setURL(url) { this.data.url = url; return this; } /** * Sets the label for the button. * @param label - The label to set. * @returns The modified Button instance. */ setLabel(label) { this.data.label = label; return this; } /** * Sets the emoji for the button. * @param emoji - The emoji to set. * @returns The modified Button instance. */ setEmoji(emoji) { const resolve = (0, common_1.resolvePartialEmoji)(emoji); if (!resolve) throw new common_1.SeyfertError('INVALID_EMOJI', { metadata: { ...(0, common_1.createValidationMetadata)('EmojiResolvable', emoji, { component: 'Button' }), detail: 'Invalid Emoji', }, }); this.data.emoji = resolve; return this; } /** * Sets the disabled state of the button. * @param disabled - Whether the button should be disabled or not. * @returns The modified Button instance. */ setDisabled(disabled = true) { this.data.disabled = disabled; return this; } setStyle(style) { this.data.style = style; return this; } setSKUId(skuId) { this.data.sku_id = skuId; return this; } } exports.Button = Button;