diff --git a/src/structures/RichEmbed.js b/src/structures/RichEmbed.js index a62e58833..c135a6219 100644 --- a/src/structures/RichEmbed.js +++ b/src/structures/RichEmbed.js @@ -104,10 +104,15 @@ class RichEmbed { */ setColor(color) { if (color instanceof Array) { - color = parseInt(((1 << 24) + (color[0] << 16) + (color[1] << 8) + color[2]).toString(16).slice(1), 16); + color = (color[0] << 16) + (color[1] << 8) + color[2]; } else if (typeof color === 'string' && color.startsWith('#')) { color = parseInt(color.replace('#', ''), 16); } + if (color < 0 || color > 0xFFFFFF) { + throw new RangeError('RichEmbed color must be within the range 0 - 16777215 (0xFFFFFF).'); + } else if (color && isNaN(parseInt(color))) { + throw new TypeError('Unable to convert RichEmbed color to a number.'); + } this.color = color; return this; } @@ -115,7 +120,7 @@ class RichEmbed { /** * Sets the author of this embed * @param {string} name The name of the author - * @param {string} [icon] The icon of the author + * @param {string} [icon] The icon URL of the author * @returns {RichEmbed} This embed */ setAuthor(name, icon) { @@ -171,7 +176,7 @@ class RichEmbed { /** * Sets the footer of this embed * @param {string} text The text of the footer - * @param {string} icon The icon of the footer + * @param {string} [icon] The icon URL of the footer * @returns {RichEmbed} This embed */ setFooter(text, icon) { diff --git a/test/random.js b/test/random.js index f3af346a7..d6c761ea5 100644 --- a/test/random.js +++ b/test/random.js @@ -13,7 +13,7 @@ client.login(token).then(atoken => console.log('logged in with token ' + atoken) client.ws.on('send', console.log); client.on('ready', () => { - console.log('ready!'); + console.log('ready'); }); client.on('userUpdate', (o, n) => {