Skip to content

Commit 53441ab

Browse files
fix: accept non integer user IDs
1 parent 7552855 commit 53441ab

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/utils/getAvatar.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ function getAvatar(
5757
user: APIUser,
5858
{ animated = false, size = 80, forceDefault = false }: GetAvatarOptions = {}
5959
): string {
60-
const defaultAvatar = `https://cdn.discordapp.com/embed/avatars/${
61-
Number(BigInt(user.id) >> 22n) % 6
62-
}.png`;
60+
const defaultAvatarIndex = isNaN(Number(user.id))
61+
? 0
62+
: Number(BigInt(user.id) >> 22n) % 6;
63+
64+
const defaultAvatar = `https://cdn.discordapp.com/embed/avatars/${defaultAvatarIndex}.png`;
6365

6466
const avatarUrl = getAvatarProperty(user, size);
6567

0 commit comments

Comments
 (0)