.webp => .png

This commit is contained in:
minibox24 2020-12-04 17:57:59 +09:00
parent e553888c1c
commit 84c106655c
2 changed files with 3 additions and 3 deletions

View file

@ -3,11 +3,11 @@ import { ImageFormats, ImageSize } from '../types/cdn.ts'
/** Function to get Image URL from a resource on Discord CDN */
export const ImageURL = (
url: string,
format: ImageFormats | undefined = 'webp',
format: ImageFormats | undefined = 'png',
size: ImageSize | undefined = 128
): string => {
size = size === undefined ? 128 : size
if (url.includes('a_')) {
return `${url}.${format === undefined ? 'gif' : format}?size=${size}`
} else return `${url}.${format === 'gif' ? 'webp' : format}?size=${size}`
} else return `${url}.${format === 'gif' ? 'png' : format}?size=${size}`
}

View file

@ -40,7 +40,7 @@ export class User extends Base {
return `<@${this.id}>`
}
avatarURL(format: ImageFormats = 'webp', size: ImageSize = 512): string {
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`