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:
Jiralite 2024-02-03 21:42:16 +00:00 committed by GitHub
parent b16647e6cc
commit d4472f85a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;