mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
feat: new changes to avatarURL method over GuildMember & User (#194)
* fix(GuildMember#avatarURL): use dynamic response, to return gif avatar if the avatar is a gif * fix(User#avatarURL): dynamic response, if avatar is a gif return gif * fix(avatarURL): specified extension is being overriden by gif if avatar starts with a_ * chore: change in parseCDNURL so it's effective for almost everything * chore: re-add GuildMember#dynamicAvatarURL * fix(GuildEmoji#create): returns void while it should return the resolve promise of the created emoji --------- Co-authored-by: NotAditya69 <90441096+NotAditya69@users.noreply.github.com>
This commit is contained in:
parent
42b682d8fd
commit
00640bfda7
@ -73,6 +73,7 @@ export interface CDNUrlOptions extends BaseCDNUrlOptions {
|
||||
|
||||
export function parseCDNURL(route: string, options: CDNUrlOptions = {}) {
|
||||
if (options.forceStatic && route.includes('a_')) options.extension = 'png';
|
||||
if (!options.extension && route.includes('a_')) options.extension = 'gif';
|
||||
|
||||
const url = new URL(`${route}.${options.extension || 'png'}`);
|
||||
|
||||
|
@ -39,7 +39,9 @@ export class EmojiShorter extends BaseShorter {
|
||||
const emoji = await this.client.proxy.guilds(guildId).emojis.post({
|
||||
body: bodyResolved,
|
||||
});
|
||||
|
||||
await this.client.cache.emojis?.setIfNI('GuildEmojisAndStickers', emoji.id!, guildId, emoji);
|
||||
|
||||
return new GuildEmoji(this.client, emoji, guildId);
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,11 @@ export class GuildMember extends BaseGuildMember {
|
||||
}
|
||||
|
||||
avatarURL(options?: ImageOptions) {
|
||||
return this.user.avatarURL(options);
|
||||
if (!this.avatar) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.rest.cdn.guilds(this.guildId).users(this.id).avatars(this.avatar).get(options);
|
||||
}
|
||||
|
||||
dynamicAvatarURL(options?: ImageOptions) {
|
||||
|
@ -37,6 +37,7 @@ export class User extends DiscordBase<APIUser> {
|
||||
if (!this.avatar) {
|
||||
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