UNPKG

@shgysk8zer0/slack

Version:

An npm package for sending messages in Slack

42 lines (33 loc) 739 B
'use strict'; var element = require('./element.cjs'); class SlackTextElement extends element.SlackElement { #text; constructor(text, { id } = {}) { super({ id }); this.text = text; } get text() { return this.#text; } set text(val) { if (typeof val === 'string' && val.length !== 0) { this.#text = val; } else if (typeof val === 'number' || val instanceof URL) { this.#text = val.toString(); } else if (typeof val === 'boolean') { this.#text = val ? 'true' : 'false'; } else { throw new TypeError('text must be a non-empty string.'); } } toString() { return this.#text; } toJSON() { return { ...super.toJSON(), text: this.#text, }; } } exports.SlackTextElement = SlackTextElement;