Skip to content

Commit d4472f8

Browse files
Jiralitekodiakhq[bot]
andauthoredFeb 3, 2024
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>
1 parent b16647e commit d4472f8

File tree

1 file changed

+4
-4
lines changed
  • packages/discord.js/src/util

1 file changed

+4
-4
lines changed
 

‎packages/discord.js/src/util/Util.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,12 @@ function resolveColor(color) {
289289
resolvedColor = (color[0] << 16) + (color[1] << 8) + color[2];
290290
}
291291

292-
if (resolvedColor < 0 || resolvedColor > 0xffffff) {
293-
throw new DiscordjsRangeError(ErrorCodes.ColorRange);
292+
if (!Number.isInteger(resolvedColor)) {
293+
throw new DiscordjsTypeError(ErrorCodes.ColorConvert, color);
294294
}
295295

296-
if (typeof resolvedColor !== 'number' || Number.isNaN(resolvedColor)) {
297-
throw new DiscordjsTypeError(ErrorCodes.ColorConvert, color);
296+
if (resolvedColor < 0 || resolvedColor > 0xffffff) {
297+
throw new DiscordjsRangeError(ErrorCodes.ColorRange);
298298
}
299299

300300
return resolvedColor;

0 commit comments

Comments
 (0)
Please sign in to comment.