mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
Clean up colour resolver
This commit is contained in:
@@ -354,6 +354,7 @@ class ClientDataResolver {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Resolves a ColorResolvable into a color number
|
||||||
* @param {ColorResolvable} color Color to resolve
|
* @param {ColorResolvable} color Color to resolve
|
||||||
* @returns {number} A color
|
* @returns {number} A color
|
||||||
*/
|
*/
|
||||||
@@ -363,11 +364,13 @@ class ClientDataResolver {
|
|||||||
} else if (color instanceof Array) {
|
} else if (color instanceof Array) {
|
||||||
color = (color[0] << 16) + (color[1] << 8) + color[2];
|
color = (color[0] << 16) + (color[1] << 8) + color[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (color < 0 || color > 0xFFFFFF) {
|
if (color < 0 || color > 0xFFFFFF) {
|
||||||
throw new RangeError('Color must be within the range 0 - 16777215 (0xFFFFFF).');
|
throw new RangeError('Color must be within the range 0 - 16777215 (0xFFFFFF).');
|
||||||
} else if (color && isNaN(color)) {
|
} else if (color && isNaN(color)) {
|
||||||
throw new TypeError('Unable to convert color to a number.');
|
throw new TypeError('Unable to convert color to a number.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,7 +379,7 @@ class ClientDataResolver {
|
|||||||
* @returns {number} A color
|
* @returns {number} A color
|
||||||
*/
|
*/
|
||||||
resolveColor(color) {
|
resolveColor(color) {
|
||||||
return ClientDataResolver.resolveColor(color);
|
return this.constructor.resolveColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user