UNPKG

seyfert

Version:

The most advanced framework for discord bots

44 lines (43 loc) 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Label = void 0; const common_1 = require("../common"); const types_1 = require("../types"); const _1 = require("."); const Base_1 = require("./Base"); class Label extends Base_1.BaseComponentBuilder { constructor({ component, ...data } = {}) { super({ type: types_1.ComponentType.Label, ...data }); if (component) this.component = (0, _1.fromComponent)(component); } component; setLabel(label) { this.data.label = label; return this; } setDescription(description) { this.data.description = description; return this; } setComponent(component) { this.component = component; return this; } toJSON() { if (!this.component) throw new common_1.SeyfertError('MISSING_COMPONENT', { metadata: { ...(0, common_1.createValidationMetadata)('component to be set before calling toJSON()', this.component, { component: 'Label', }), detail: 'Cannot convert to JSON without a component.', }, }); return { ...this.data, component: this.component.toJSON(), }; } } exports.Label = Label;