Merge branch 'main' of https://github.com/harmony-org/harmony into main
This commit is contained in:
commit
9c67ff6c84
2 changed files with 14 additions and 1 deletions
|
@ -10,4 +10,4 @@ export const ImageURL = (
|
||||||
if (url.includes('a_')) {
|
if (url.includes('a_')) {
|
||||||
return `${url}.${format === undefined ? 'gif' : format}?size=${size}`
|
return `${url}.${format === undefined ? 'gif' : format}?size=${size}`
|
||||||
} else return `${url}.${format === 'gif' ? 'png' : format}?size=${size}`
|
} else return `${url}.${format === 'gif' ? 'png' : format}?size=${size}`
|
||||||
}
|
}
|
|
@ -2,6 +2,9 @@ import { Client } from '../models/client.ts'
|
||||||
import { UserPayload } from '../types/user.ts'
|
import { UserPayload } from '../types/user.ts'
|
||||||
import { UserFlagsManager } from '../utils/userFlags.ts'
|
import { UserFlagsManager } from '../utils/userFlags.ts'
|
||||||
import { Base } from './base.ts'
|
import { Base } from './base.ts'
|
||||||
|
import { ImageURL } from './cdn.ts'
|
||||||
|
import { ImageSize, ImageFormats } from '../types/cdn.ts'
|
||||||
|
import { DEFAULT_USER_AVATAR, USER_AVATAR } from '../types/endpoint.ts'
|
||||||
|
|
||||||
export class User extends Base {
|
export class User extends Base {
|
||||||
id: string
|
id: string
|
||||||
|
@ -37,6 +40,16 @@ export class User extends Base {
|
||||||
return `<@${this.id}>`
|
return `<@${this.id}>`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
avatarURL(format: ImageFormats = 'png', size: ImageSize = 512): string {
|
||||||
|
return this.avatar != null
|
||||||
|
? `${ImageURL(USER_AVATAR(this.id, this.avatar), format, size)}`
|
||||||
|
: `${DEFAULT_USER_AVATAR(String(Number(this.discriminator) % 5))}.png`
|
||||||
|
}
|
||||||
|
|
||||||
|
get defaultAvatarURL(): string {
|
||||||
|
return `${DEFAULT_USER_AVATAR(String(Number(this.discriminator) % 5))}.png`
|
||||||
|
}
|
||||||
|
|
||||||
constructor(client: Client, data: UserPayload) {
|
constructor(client: Client, data: UserPayload) {
|
||||||
super(client, data)
|
super(client, data)
|
||||||
this.id = data.id
|
this.id = data.id
|
||||||
|
|
Loading…
Reference in a new issue