diff --git a/src/classes/Channel.ts b/src/classes/Channel.ts index 0f644973..02220ccc 100644 --- a/src/classes/Channel.ts +++ b/src/classes/Channel.ts @@ -307,26 +307,14 @@ export class Channel { * URL to the channel icon */ get iconURL() { - return ( - this.icon?.createFileURL({ max_side: 256 }) ?? this.recipient?.avatarURL - ); - } - - /** - * URL to a small variant of the channel icon - */ - get smallIconURL() { - return this.icon?.createFileURL({ max_side: 64 }); + return this.icon?.createFileURL() ?? this.recipient?.avatarURL; } /** * URL to the animated channel icon */ get animatedIconURL() { - return ( - this.icon?.createFileURL({ max_side: 256 }, true) ?? - this.recipient?.animatedAvatarURL - ); + return this.icon?.createFileURL(true) ?? this.recipient?.animatedAvatarURL; } /** diff --git a/src/classes/ChannelWebhook.ts b/src/classes/ChannelWebhook.ts index ab823956..aa73fcf9 100644 --- a/src/classes/ChannelWebhook.ts +++ b/src/classes/ChannelWebhook.ts @@ -45,7 +45,7 @@ export class ChannelWebhook { get avatarURL() { return this.#collection .getUnderlyingObject(this.id) - .avatar?.createFileURL({ max_side: 256 }); + .avatar?.createFileURL(); } /** diff --git a/src/classes/File.ts b/src/classes/File.ts index 10568597..ce40d07c 100644 --- a/src/classes/File.ts +++ b/src/classes/File.ts @@ -98,41 +98,16 @@ export class File { /** * Creates a URL to a given file with given options. - * @param options Optional query parameters to modify object - * @param allowAnimation Returns GIF if applicable, no operations occur on image + * @param forceAnimation Returns GIF if applicable (for avatars/icons) * @returns Generated URL or nothing */ - createFileURL( - options?: { - max_side?: number; - size?: number; - width?: number; - height?: number; - }, - allowAnimation?: boolean - ) { + createFileURL(forceAnimation?: boolean) { const autumn = this.#client.configuration?.features.autumn; if (!autumn?.enabled) return; - // TODO: server-side - if (this.metadata?.type === "Image") { - if ( - Math.min(this.metadata.width, this.metadata.height) <= 0 || - (this.contentType === "image/gif" && - Math.max(this.metadata.width, this.metadata.height) >= 4096) - ) - return; - } - let query = ""; - if (options) { - if (!allowAnimation || this.contentType !== "image/gif") { - query = - "?" + - Object.keys(options) - .map((k) => `${k}=${options[k as keyof typeof options]}`) - .join("&"); - } + if (forceAnimation && this.contentType === "image/gif") { + query = "/original"; } return `${autumn.url}/${this.tag}/${this.id}${query}`; diff --git a/src/classes/Message.ts b/src/classes/Message.ts index 138ce13f..76a7b38c 100644 --- a/src/classes/Message.ts +++ b/src/classes/Message.ts @@ -380,7 +380,7 @@ export class MessageWebhook { */ get avatarURL() { return ( - this.avatar?.createFileURL({ max_side: 256 }) ?? + this.avatar?.createFileURL() ?? `${this.#client.options.baseURL}/users/${this.id}/default_avatar` ); } diff --git a/src/classes/Server.ts b/src/classes/Server.ts index 73bd56fc..38f58a81 100644 --- a/src/classes/Server.ts +++ b/src/classes/Server.ts @@ -285,21 +285,21 @@ export class Server { * URL to the server's icon */ get iconURL() { - return this.icon?.createFileURL({ max_side: 256 }); + return this.icon?.createFileURL(); } /** * URL to the server's animated icon */ get animatedIconURL() { - return this.icon?.createFileURL({ max_side: 256 }, true); + return this.icon?.createFileURL(true); } /** * URL to the server's banner */ get bannerURL() { - return this.banner?.createFileURL({ max_side: 256 }, true); + return this.banner?.createFileURL(); } /** diff --git a/src/classes/ServerMember.ts b/src/classes/ServerMember.ts index 002fa7f5..d408061f 100644 --- a/src/classes/ServerMember.ts +++ b/src/classes/ServerMember.ts @@ -207,19 +207,14 @@ export class ServerMember { * URL to the member's avatar */ get avatarURL() { - return ( - this.avatar?.createFileURL({ max_side: 256 }) ?? this.user?.avatarURL - ); + return this.avatar?.createFileURL() ?? this.user?.avatarURL; } /** * URL to the member's animated avatar */ get animatedAvatarURL() { - return ( - this.avatar?.createFileURL({ max_side: 256 }, true) ?? - this.user?.animatedAvatarURL - ); + return this.avatar?.createFileURL(true) ?? this.user?.animatedAvatarURL; } /** diff --git a/src/classes/User.ts b/src/classes/User.ts index 072e8d52..b664c910 100644 --- a/src/classes/User.ts +++ b/src/classes/User.ts @@ -147,19 +147,14 @@ export class User { * URL to the user's avatar */ get avatarURL() { - return ( - this.avatar?.createFileURL({ max_side: 256 }) ?? this.defaultAvatarURL - ); + return this.avatar?.createFileURL() ?? this.defaultAvatarURL; } /** * URL to the user's animated avatar */ get animatedAvatarURL() { - return ( - this.avatar?.createFileURL({ max_side: 256 }, true) ?? - this.defaultAvatarURL - ); + return this.avatar?.createFileURL(true) ?? this.defaultAvatarURL; } /**