mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-21 15:54:44 +12:00
refactor(resolveColor): Prioritise number type check (#10116)
* refactor(resolveColor): prioritise number type check * refactor: prefer `!Number.isInteger()` --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
parent
b16647e6cc
commit
d4472f85a5
1 changed files with 4 additions and 4 deletions
|
@ -289,12 +289,12 @@ function resolveColor(color) {
|
|||
resolvedColor = (color[0] << 16) + (color[1] << 8) + color[2];
|
||||
}
|
||||
|
||||
if (resolvedColor < 0 || resolvedColor > 0xffffff) {
|
||||
throw new DiscordjsRangeError(ErrorCodes.ColorRange);
|
||||
if (!Number.isInteger(resolvedColor)) {
|
||||
throw new DiscordjsTypeError(ErrorCodes.ColorConvert, color);
|
||||
}
|
||||
|
||||
if (typeof resolvedColor !== 'number' || Number.isNaN(resolvedColor)) {
|
||||
throw new DiscordjsTypeError(ErrorCodes.ColorConvert, color);
|
||||
if (resolvedColor < 0 || resolvedColor > 0xffffff) {
|
||||
throw new DiscordjsRangeError(ErrorCodes.ColorRange);
|
||||
}
|
||||
|
||||
return resolvedColor;
|
||||
|
|
Loading…
Reference in a new issue