Skip to content

Commit

Permalink
refactor(resolveColor): Prioritise number type check (#10116)
Browse files Browse the repository at this point in the history
* refactor(resolveColor): prioritise number type check

* refactor: prefer `!Number.isInteger()`

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
Jiralite and kodiakhq[bot] authored Feb 3, 2024
1 parent b16647e commit d4472f8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/discord.js/src/util/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d4472f8

Please sign in to comment.