mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 04:56:07 +00:00
fix: use calculateUserDefaultAvatarIndex function
This commit is contained in:
parent
0392de7964
commit
28133b2c1f
@ -5,8 +5,8 @@ import type { Snowflake } from 'discord-api-types/v10';
|
||||
*
|
||||
* @param userId - The user id to calculate the default avatar index for
|
||||
*/
|
||||
export function calculateUserDefaultAvatarIndex(userId: Snowflake) {
|
||||
return Number(BigInt(userId) >> 22n) % 6;
|
||||
export function calculateUserDefaultAvatarIndex(userId: Snowflake, discriminator: string) {
|
||||
return discriminator === '0' ? Number(BigInt(userId) >> 22n) % 6 : Number.parseInt(discriminator) % 5;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,5 @@
|
||||
import type { APIUser } from 'discord-api-types/v10';
|
||||
import { calculateUserDefaultAvatarIndex } from '../api';
|
||||
import type { MessageCreateBodyRequest, ObjectToLower } from '../common';
|
||||
import type { ImageOptions } from '../common/types/options';
|
||||
import { DiscordBase } from './extra/DiscordBase';
|
||||
@ -34,9 +35,7 @@ export class User extends DiscordBase<APIUser> {
|
||||
|
||||
avatarURL(options?: ImageOptions) {
|
||||
if (!this.avatar) {
|
||||
const avatarIndex =
|
||||
this.discriminator === '0' ? Number(BigInt(this.id) >> 22n) % 6 : Number.parseInt(this.discriminator) % 5;
|
||||
return this.rest.cdn.embed.avatars.get(avatarIndex);
|
||||
return this.rest.cdn.embed.avatars.get(calculateUserDefaultAvatarIndex(this.id, this.discriminator));
|
||||
}
|
||||
return this.rest.cdn.avatars(this.id).get(this.avatar, options);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user