UNPKG

ghost-music.js

Version:

Müzik için tasarlanan modüldür!

66 lines (54 loc) 1.5 kB
const { BaseMessageComponent, Constants, Util } = require('discord.js'); class Button extends BaseMessageComponent { constructor(data = {}) { super({ type: 'BUTTON' }); this.setup(data); } setup(data) { this.label = data.label || null; this.customId = data.custom_id || data.customId || null; this.style = data.style ? MessageButton.resolveStyle(data.style) : null; this.emoji = data.emoji ? Util.resolvePartialEmoji(data.emoji) : null; this.url = data.url || null; this.disabled = data.disabled || false; } setID(customId) { this.customId = Util.verifyString(customId); return this; } setDisabled(disabled) { this.disabled = disabled; return this; } setEmoji(emoji) { this.emoji = Util.resolvePartialEmoji(emoji); return this; } setLabel(label) { this.label = Util.verifyString(label); return this; } setStyle(style) { this.style = MessageButton.resolveStyle(style); return this; } setURL(url) { this.url = Util.verifyString(url); return this; } toJSON() { return { custom_id: this.customId, disabled: this.disabled, emoji: this.emoji, label: this.label, style: Constants.MessageButtonStyles[this.style], type: Constants.MessageComponentTypes[this.type], url: this.url, }; } static resolveStyle(style) { return typeof style === 'string' ? style : Constants.MessageButtonStyles[style]; } } module.exports = Button;