mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
new errors for richembed yay (#966)
* Update faq.md (#949) * fix docs * Revert "fixed typo in documentation" (#950) * new errors for richembed yay Simplified the parsing for color arrays. Throwing some errors on values that would result in Bad Requests. Changed setAuthor and setFooter's icon parameter to icon_url to match the embed object's property name. Changed the docs for setFooter to reflect that icon_url is optional. * changed docs instead of arg names * capitalization
This commit is contained in:
committed by
Schuyler Cebulskie
parent
c5f93eb44e
commit
b79a91b3a9
@@ -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) {
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user