diff --git a/src/util/builder/buttonBuilder.js b/src/util/builder/buttonBuilder.js index 0fb929bd1..bc905d370 100644 --- a/src/util/builder/buttonBuilder.js +++ b/src/util/builder/buttonBuilder.js @@ -19,6 +19,9 @@ class Button { * @returns {Button} */ setLabel(label) { + + if (!label) throw new TypeError("GLUON: Button label must be provided."); + this.label = label; return this; @@ -32,6 +35,8 @@ class Button { setEmoji(emoji) { this.emoji = resolveEmoji(emoji); + if (!this.emoji) throw new TypeError("GLUON: Button emoji must be provided."); + return this; } diff --git a/src/util/discord/resolveEmoji.js b/src/util/discord/resolveEmoji.js index 5518847f9..841fc24ed 100644 --- a/src/util/discord/resolveEmoji.js +++ b/src/util/discord/resolveEmoji.js @@ -5,9 +5,17 @@ * @returns {Object} */ function resolveEmoji(text) { + + if (typeof text !== "string") + throw new TypeError("GLUON: The emoji must be a string."); + const emojis = text.match(/<:[^:\s]+:[0-9]+>|/g); - if (!emojis || emojis.length == 0) return null; + if (!emojis || emojis.length == 0) { + if (/\p{Extended_Pictographic}/u.test(text)) + return { name: text, id: null }; + return null; + } const splitEmoji = emojis[0].replace(/<|>/g, "").split(":");