Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use new default avatar calculation
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent df47920 commit 658e2f3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions components/Navigation.tsx
Expand Up @@ -27,10 +27,10 @@ async function destroySession() {
function getAvatarUrl(userData: { [k: string]: any }): string {
const BASE = "https://cdn.discordapp.com/";

if (!userData.id) return "";
if (!userData.id || typeof window["BigInt"] === "undefined") return "";

if (!userData.avatar)
return BASE + `embed/avatars/${parseInt(userData.discriminator) % 5}.png`;
return BASE + `embed/avatars/${(BigInt(userData.id) >> 22n) % 6n}.png`;

return BASE + `avatars/${userData.id}/${userData.avatar}`;
}
Expand Down Expand Up @@ -151,9 +151,7 @@ export default function (props: {
display={data.id ? "flex" : "none"}
src={getAvatarUrl(data)}
/>
<Text>
{data.id ? `${data.username}#${data.discriminator}` : ""}
</Text>
<Text>{data.id ? data.username : ""}</Text>
<Button
onClick={async () => await destroySession()}
size="md"
Expand Down Expand Up @@ -203,7 +201,7 @@ export default function (props: {
</Link>
<Avatar display={data.id ? "" : "none"} src={getAvatarUrl(data)} />
<Text align="center" style={{ overflowWrap: "anywhere" }}>
{data.id ? `${data.username}#${data.discriminator}` : ""}
{data.id ? data.username : ""}
</Text>
<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down

0 comments on commit 658e2f3

Please sign in to comment.