| 92 | } |
| 93 | |
| 94 | export function createLinkButton(label, url, emoji = null) { |
| 95 | |
| 96 | if (!label || typeof label !== 'string') { |
| 97 | throw new Error('label must be a non-empty string'); |
| 98 | } |
| 99 | if (!url || typeof url !== 'string') { |
| 100 | throw new Error('url must be a non-empty string'); |
| 101 | } |
| 102 | |
| 103 | const validLabel = label.substring(0, 80); |
| 104 | |
| 105 | const button = new ButtonBuilder() |
| 106 | .setLabel(validLabel) |
| 107 | .setURL(url) |
| 108 | .setStyle(ButtonStyle.Link); |
| 109 | |
| 110 | if (emoji && typeof emoji === 'string' && emoji.length > 0) { |
| 111 | try { |
| 112 | button.setEmoji(emoji); |
| 113 | } catch (error) { |
| 114 | |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | return button; |
| 119 | } |
| 120 | |
| 121 | export function createButtonRow(buttons) { |
| 122 | const row = new ActionRowBuilder(); |