UNPKG

vk-bot-sdk

Version:

NodeJS Lib for VK API

72 lines (57 loc) 1.24 kB
class Button { constructor({ color = Button.DEFAULT_COLOR, action }) { this.color = color; const payload = JSON.stringify( action.payload || {} ); if( payload.length > 255 ) { return console.error( 'Maximum length of payload 255 characters' ); } this.action = { ...action, payload }; } /** * Returns the default color (#FFFFFF) * * @return {string} */ static get DEFAULT_COLOR() { return 'default'; } /** * Returns the primary color (#5181B8) * * @return {string} */ static get PRIMARY_COLOR() { return 'primary'; } /** * Returns the negative color (#E64646) * * @return {string} */ static get NEGATIVE_COLOR() { return 'negative'; } /** * Returns the positive color (#4BB34B) * * @return {string} */ static get POSITIVE_COLOR() { return 'positive'; } /** * Returns to JSON * * @return {Object} */ toJSON() { return { color: this.color, action: this.action } } } module.exports = Button;