From 20c1bc8e4c123f61b07db2091b351ecdb0f9972d Mon Sep 17 00:00:00 2001 From: Ventus <29584664+V3ntus@users.noreply.github.com> Date: Tue, 11 Apr 2023 10:57:27 -0500 Subject: [PATCH 1/6] ref: nullable `animated` for icon/avatar/splash URL properties (#475) feat: animated icon/avatar/splash URL helpers on null --- lib/src/core/guild/guild.dart | 12 ++++++++---- lib/src/core/guild/guild_preview.dart | 6 ++++-- lib/src/core/guild/webhook.dart | 6 ++++-- lib/src/core/user/member.dart | 6 ++++-- lib/src/core/user/user.dart | 10 +++++++--- lib/src/internal/interfaces/message_author.dart | 2 +- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/lib/src/core/guild/guild.dart b/lib/src/core/guild/guild.dart index 315ec1894..1962e4ef0 100644 --- a/lib/src/core/guild/guild.dart +++ b/lib/src/core/guild/guild.dart @@ -199,7 +199,7 @@ abstract class IGuild implements SnowflakeEntity { /// The guild's icon, represented as URL. /// If guild doesn't have icon it returns null. - String? iconUrl({String format = 'webp', int? size, bool animated = false}); + String? iconUrl({String format = 'webp', int? size, bool? animated}); /// URL to guild's splash. /// If guild doesn't have splash it returns null. @@ -211,7 +211,7 @@ abstract class IGuild implements SnowflakeEntity { /// URL to guild's banner. /// If guild doesn't have banner it returns null. - String? bannerUrl({String format = 'webp', int? size, bool animated = false}); + String? bannerUrl({String format = 'webp', int? size, bool? animated}); /// Allows to download [IGuild] widget aka advert png /// Possible options for [style]: shield (default), banner1, banner2, banner3, banner4 @@ -730,11 +730,13 @@ class Guild extends SnowflakeEntity implements IGuild { /// The guild's icon, represented as URL. /// If guild doesn't have icon it returns null. @override - String? iconUrl({String format = 'webp', int? size, bool animated = false}) { + String? iconUrl({String format = 'webp', int? size, bool? animated}) { if (icon == null) { return null; } + animated ??= icon?.startsWith("a_") ?? false; + return client.cdnHttpEndpoints.icon(id, icon!, format: format, size: size, animated: animated); } @@ -768,11 +770,13 @@ class Guild extends SnowflakeEntity implements IGuild { /// Returns the URL to guild's banner. /// If guild doesn't have banner it returns null. @override - String? bannerUrl({String format = 'webp', int? size, bool animated = false}) { + String? bannerUrl({String format = 'webp', int? size, bool? animated}) { if (banner == null) { return null; } + animated ??= banner?.startsWith("a_") ?? false; + return client.cdnHttpEndpoints.banner(id, banner!, format: format, size: size, animated: animated); } diff --git a/lib/src/core/guild/guild_preview.dart b/lib/src/core/guild/guild_preview.dart index e0e559e97..4c697d9ed 100644 --- a/lib/src/core/guild/guild_preview.dart +++ b/lib/src/core/guild/guild_preview.dart @@ -38,7 +38,7 @@ abstract class IGuildPreview implements SnowflakeEntity { /// The guild's icon, represented as URL. /// If guild doesn't have icon it returns null. - String? iconUrl({String format = 'webp', int? size, bool animated = false}); + String? iconUrl({String format = 'webp', int? size, bool? animated}); /// URL to guild's splash. /// If guild doesn't have splash it returns null. @@ -115,11 +115,13 @@ class GuildPreview extends SnowflakeEntity implements IGuildPreview { /// The guild's icon, represented as URL. /// If guild doesn't have icon it returns null. @override - String? iconUrl({String format = 'webp', int? size, bool animated = false}) { + String? iconUrl({String format = 'webp', int? size, bool? animated}) { if (iconHash == null) { return null; } + animated ??= iconHash?.startsWith("a_") ?? false; + return client.cdnHttpEndpoints.icon(id, iconHash!, format: format, size: size, animated: animated); } diff --git a/lib/src/core/guild/webhook.dart b/lib/src/core/guild/webhook.dart index 10883d104..86b639206 100644 --- a/lib/src/core/guild/webhook.dart +++ b/lib/src/core/guild/webhook.dart @@ -79,7 +79,7 @@ abstract class IWebhook implements SnowflakeEntity, IMessageAuthor { Future execute(MessageBuilder builder, {bool wait = true, Snowflake? threadId, String? threadName, String? avatarUrl, String? username}); @override - String avatarUrl({String format = 'webp', int? size, bool animated = false}); + String avatarUrl({String format = 'webp', int? size, bool? animated}); /// Edits the webhook. Future edit({String? name, SnowflakeEntity? channel, AttachmentBuilder? avatarAttachment, String? auditReason}); @@ -187,11 +187,13 @@ class Webhook extends SnowflakeEntity implements IWebhook { .executeWebhook(id, builder, token: token, threadId: threadId, username: username, wait: wait, avatarUrl: avatarUrl, threadName: threadName); @override - String avatarUrl({String format = 'webp', int? size, bool animated = false}) { + String avatarUrl({String format = 'webp', int? size, bool? animated}) { if (avatarHash == null) { return client.cdnHttpEndpoints.defaultAvatar(defaultAvatarId); } + animated ??= avatarHash?.startsWith("a_") ?? false; + return client.cdnHttpEndpoints.avatar(id, avatarHash!, format: format, size: size, animated: animated); } diff --git a/lib/src/core/user/member.dart b/lib/src/core/user/member.dart index 24f8ad688..899e7b35f 100644 --- a/lib/src/core/user/member.dart +++ b/lib/src/core/user/member.dart @@ -72,7 +72,7 @@ abstract class IMember implements SnowflakeEntity, Mentionable { /// The member's avatar, represented as URL. With given [format] and [size]. /// If [animated] is set as `true`, if available, the url will be a gif, otherwise the [format] or fallback to "webp". - String? avatarUrl({String format = 'webp', int? size, bool animated = false}); + String? avatarUrl({String format = 'webp', int? size, bool? animated}); /// Bans the member and optionally deletes [deleteMessageDays] days worth of messages. Future ban({int? deleteMessageDays, String? reason, String? auditReason}); @@ -208,11 +208,13 @@ class Member extends SnowflakeEntity implements IMember { /// Returns url to member avatar @override - String? avatarUrl({String format = 'webp', int? size, bool animated = false}) { + String? avatarUrl({String format = 'webp', int? size, bool? animated}) { if (avatarHash == null) { return null; } + animated ??= avatarHash?.startsWith("a_") ?? false; + return client.cdnHttpEndpoints.memberAvatar(guild.id, id, avatarHash!, format: format, size: size, animated: animated); } diff --git a/lib/src/core/user/user.dart b/lib/src/core/user/user.dart index e32b8f016..ee3fd7ea9 100644 --- a/lib/src/core/user/user.dart +++ b/lib/src/core/user/user.dart @@ -52,7 +52,7 @@ abstract class IUser implements SnowflakeEntity, ISend, Mentionable, IMessageAut String? avatarDecorationHash; /// The user's banner url. - String? bannerUrl({String format = 'webp', int? size, bool animated = false}); + String? bannerUrl({String format = 'webp', int? size, bool? animated}); /// The user's avatar decoration url, if any. String? avatarDecorationUrl({int size}); @@ -170,21 +170,25 @@ class User extends SnowflakeEntity implements IUser { /// The user's avatar, represented as URL. /// In case if user does not have avatar, default discord avatar will be returned with specified size and png format. @override - String avatarUrl({String format = 'webp', int? size, bool animated = false}) { + String avatarUrl({String format = 'webp', int? size, bool? animated}) { if (avatar == null) { return client.cdnHttpEndpoints.defaultAvatar(discriminator); } + animated ??= avatar?.startsWith("a_") ?? false; + return client.cdnHttpEndpoints.avatar(id, avatar!, format: format, size: size, animated: animated); } /// The user's banner url. @override - String? bannerUrl({String format = 'webp', int? size, bool animated = false}) { + String? bannerUrl({String format = 'webp', int? size, bool? animated}) { if (bannerHash == null) { return null; } + animated ??= bannerHash?.startsWith("a_") ?? false; + return client.cdnHttpEndpoints.banner(id, bannerHash!, format: format, size: size, animated: animated); } diff --git a/lib/src/internal/interfaces/message_author.dart b/lib/src/internal/interfaces/message_author.dart index b7c9ff35e..609af4d8f 100644 --- a/lib/src/internal/interfaces/message_author.dart +++ b/lib/src/internal/interfaces/message_author.dart @@ -24,5 +24,5 @@ abstract class IMessageAuthor implements SnowflakeEntity { /// The user's avatar, represented as URL. /// In case if user does not have avatar, default discord avatar will be returned; [format], [size] and [animated] will no longer affectng this URL. /// If [animated] is set as `true`, if available, the url will be a gif, otherwise the [format]. - String avatarUrl({String format = 'webp', int? size, bool animated = false}); + String avatarUrl({String format = 'webp', int? size, bool? animated}); } From ce85712fd830e9fc175003052afda124ec0ec3c4 Mon Sep 17 00:00:00 2001 From: Rapougnac <74512338+Rapougnac@users.noreply.github.com> Date: Wed, 12 Apr 2023 06:47:56 +0200 Subject: [PATCH 2/6] Revert #475 (#476) * Revert "ref: nullable `animated` for icon/avatar/splash URL properties (#475)" This reverts commit 20c1bc8e4c123f61b07db2091b351ecdb0f9972d. * fix: remove ifs * Make `true` default value for `animated` prop * [ci skip] fmt --- lib/src/core/application/app_team_user.dart | 2 +- lib/src/core/guild/guild.dart | 12 +++----- lib/src/core/guild/guild_preview.dart | 6 ++-- lib/src/core/guild/webhook.dart | 6 ++-- lib/src/core/message/guild_emoji.dart | 4 +-- lib/src/core/user/member.dart | 6 ++-- lib/src/core/user/user.dart | 10 ++----- lib/src/internal/cdn_http_endpoints.dart | 29 ++++++++----------- .../internal/interfaces/message_author.dart | 2 +- 9 files changed, 29 insertions(+), 48 deletions(-) diff --git a/lib/src/core/application/app_team_user.dart b/lib/src/core/application/app_team_user.dart index a7a75d172..3ac67fc12 100644 --- a/lib/src/core/application/app_team_user.dart +++ b/lib/src/core/application/app_team_user.dart @@ -47,7 +47,7 @@ class AppTeamUser extends SnowflakeEntity implements IAppTeamUser { } @override - String avatarUrl({String format = 'webp', int? size, bool animated = false}) { + String avatarUrl({String format = 'webp', int? size, bool animated = true}) { if (avatar == null) { return client.cdnHttpEndpoints.defaultAvatar(int.tryParse(discriminator) ?? 0); } diff --git a/lib/src/core/guild/guild.dart b/lib/src/core/guild/guild.dart index 1962e4ef0..5a3c2ed0f 100644 --- a/lib/src/core/guild/guild.dart +++ b/lib/src/core/guild/guild.dart @@ -199,7 +199,7 @@ abstract class IGuild implements SnowflakeEntity { /// The guild's icon, represented as URL. /// If guild doesn't have icon it returns null. - String? iconUrl({String format = 'webp', int? size, bool? animated}); + String? iconUrl({String format = 'webp', int? size, bool animated = true}); /// URL to guild's splash. /// If guild doesn't have splash it returns null. @@ -211,7 +211,7 @@ abstract class IGuild implements SnowflakeEntity { /// URL to guild's banner. /// If guild doesn't have banner it returns null. - String? bannerUrl({String format = 'webp', int? size, bool? animated}); + String? bannerUrl({String format = 'webp', int? size, bool animated = true}); /// Allows to download [IGuild] widget aka advert png /// Possible options for [style]: shield (default), banner1, banner2, banner3, banner4 @@ -730,13 +730,11 @@ class Guild extends SnowflakeEntity implements IGuild { /// The guild's icon, represented as URL. /// If guild doesn't have icon it returns null. @override - String? iconUrl({String format = 'webp', int? size, bool? animated}) { + String? iconUrl({String format = 'webp', int? size, bool animated = true}) { if (icon == null) { return null; } - animated ??= icon?.startsWith("a_") ?? false; - return client.cdnHttpEndpoints.icon(id, icon!, format: format, size: size, animated: animated); } @@ -770,13 +768,11 @@ class Guild extends SnowflakeEntity implements IGuild { /// Returns the URL to guild's banner. /// If guild doesn't have banner it returns null. @override - String? bannerUrl({String format = 'webp', int? size, bool? animated}) { + String? bannerUrl({String format = 'webp', int? size, bool animated = true}) { if (banner == null) { return null; } - animated ??= banner?.startsWith("a_") ?? false; - return client.cdnHttpEndpoints.banner(id, banner!, format: format, size: size, animated: animated); } diff --git a/lib/src/core/guild/guild_preview.dart b/lib/src/core/guild/guild_preview.dart index 4c697d9ed..a28021822 100644 --- a/lib/src/core/guild/guild_preview.dart +++ b/lib/src/core/guild/guild_preview.dart @@ -38,7 +38,7 @@ abstract class IGuildPreview implements SnowflakeEntity { /// The guild's icon, represented as URL. /// If guild doesn't have icon it returns null. - String? iconUrl({String format = 'webp', int? size, bool? animated}); + String? iconUrl({String format = 'webp', int? size, bool animated = true}); /// URL to guild's splash. /// If guild doesn't have splash it returns null. @@ -115,13 +115,11 @@ class GuildPreview extends SnowflakeEntity implements IGuildPreview { /// The guild's icon, represented as URL. /// If guild doesn't have icon it returns null. @override - String? iconUrl({String format = 'webp', int? size, bool? animated}) { + String? iconUrl({String format = 'webp', int? size, bool animated = true}) { if (iconHash == null) { return null; } - animated ??= iconHash?.startsWith("a_") ?? false; - return client.cdnHttpEndpoints.icon(id, iconHash!, format: format, size: size, animated: animated); } diff --git a/lib/src/core/guild/webhook.dart b/lib/src/core/guild/webhook.dart index 86b639206..25a17f657 100644 --- a/lib/src/core/guild/webhook.dart +++ b/lib/src/core/guild/webhook.dart @@ -79,7 +79,7 @@ abstract class IWebhook implements SnowflakeEntity, IMessageAuthor { Future execute(MessageBuilder builder, {bool wait = true, Snowflake? threadId, String? threadName, String? avatarUrl, String? username}); @override - String avatarUrl({String format = 'webp', int? size, bool? animated}); + String avatarUrl({String format = 'webp', int? size, bool animated = true}); /// Edits the webhook. Future edit({String? name, SnowflakeEntity? channel, AttachmentBuilder? avatarAttachment, String? auditReason}); @@ -187,13 +187,11 @@ class Webhook extends SnowflakeEntity implements IWebhook { .executeWebhook(id, builder, token: token, threadId: threadId, username: username, wait: wait, avatarUrl: avatarUrl, threadName: threadName); @override - String avatarUrl({String format = 'webp', int? size, bool? animated}) { + String avatarUrl({String format = 'webp', int? size, bool animated = true}) { if (avatarHash == null) { return client.cdnHttpEndpoints.defaultAvatar(defaultAvatarId); } - animated ??= avatarHash?.startsWith("a_") ?? false; - return client.cdnHttpEndpoints.avatar(id, avatarHash!, format: format, size: size, animated: animated); } diff --git a/lib/src/core/message/guild_emoji.dart b/lib/src/core/message/guild_emoji.dart index f85200960..1e46a153e 100644 --- a/lib/src/core/message/guild_emoji.dart +++ b/lib/src/core/message/guild_emoji.dart @@ -26,7 +26,7 @@ abstract class IBaseGuildEmoji implements SnowflakeEntity, IEmoji { /// Returns the CDN URL for this emoji with given [format] and [size]. /// If [animated] is set as `true`, an animated version of the emoji (if applicable) will be displayed. - String cdnUrl({String format = 'webp', int? size, bool animated = false}); + String cdnUrl({String format = 'webp', int? size, bool animated = true}); } abstract class BaseGuildEmoji extends SnowflakeEntity implements IBaseGuildEmoji { @@ -50,7 +50,7 @@ abstract class BaseGuildEmoji extends SnowflakeEntity implements IBaseGuildEmoji /// Returns cdn url to emoji @override - String cdnUrl({String format = 'webp', int? size, bool animated = false}) { + String cdnUrl({String format = 'webp', int? size, bool animated = true}) { return client.cdnHttpEndpoints.emoji(id, format: this.animated && animated ? 'gif' : format, size: size); } diff --git a/lib/src/core/user/member.dart b/lib/src/core/user/member.dart index 899e7b35f..74ba19d51 100644 --- a/lib/src/core/user/member.dart +++ b/lib/src/core/user/member.dart @@ -72,7 +72,7 @@ abstract class IMember implements SnowflakeEntity, Mentionable { /// The member's avatar, represented as URL. With given [format] and [size]. /// If [animated] is set as `true`, if available, the url will be a gif, otherwise the [format] or fallback to "webp". - String? avatarUrl({String format = 'webp', int? size, bool? animated}); + String? avatarUrl({String format = 'webp', int? size, bool animated = true}); /// Bans the member and optionally deletes [deleteMessageDays] days worth of messages. Future ban({int? deleteMessageDays, String? reason, String? auditReason}); @@ -208,13 +208,11 @@ class Member extends SnowflakeEntity implements IMember { /// Returns url to member avatar @override - String? avatarUrl({String format = 'webp', int? size, bool? animated}) { + String? avatarUrl({String format = 'webp', int? size, bool animated = true}) { if (avatarHash == null) { return null; } - animated ??= avatarHash?.startsWith("a_") ?? false; - return client.cdnHttpEndpoints.memberAvatar(guild.id, id, avatarHash!, format: format, size: size, animated: animated); } diff --git a/lib/src/core/user/user.dart b/lib/src/core/user/user.dart index ee3fd7ea9..78bd829f4 100644 --- a/lib/src/core/user/user.dart +++ b/lib/src/core/user/user.dart @@ -52,7 +52,7 @@ abstract class IUser implements SnowflakeEntity, ISend, Mentionable, IMessageAut String? avatarDecorationHash; /// The user's banner url. - String? bannerUrl({String format = 'webp', int? size, bool? animated}); + String? bannerUrl({String format = 'webp', int? size, bool animated = true}); /// The user's avatar decoration url, if any. String? avatarDecorationUrl({int size}); @@ -170,25 +170,21 @@ class User extends SnowflakeEntity implements IUser { /// The user's avatar, represented as URL. /// In case if user does not have avatar, default discord avatar will be returned with specified size and png format. @override - String avatarUrl({String format = 'webp', int? size, bool? animated}) { + String avatarUrl({String format = 'webp', int? size, bool animated = true}) { if (avatar == null) { return client.cdnHttpEndpoints.defaultAvatar(discriminator); } - animated ??= avatar?.startsWith("a_") ?? false; - return client.cdnHttpEndpoints.avatar(id, avatar!, format: format, size: size, animated: animated); } /// The user's banner url. @override - String? bannerUrl({String format = 'webp', int? size, bool? animated}) { + String? bannerUrl({String format = 'webp', int? size, bool animated = true}) { if (bannerHash == null) { return null; } - animated ??= bannerHash?.startsWith("a_") ?? false; - return client.cdnHttpEndpoints.banner(id, bannerHash!, format: format, size: size, animated: animated); } diff --git a/lib/src/internal/cdn_http_endpoints.dart b/lib/src/internal/cdn_http_endpoints.dart index 02420899d..c33684d8d 100644 --- a/lib/src/internal/cdn_http_endpoints.dart +++ b/lib/src/internal/cdn_http_endpoints.dart @@ -19,11 +19,11 @@ abstract class ICdnHttpEndpoints { /// Returns URL to ``/avatars/[avatarHash]``. /// With given [format], [size] and whether or not returns the animated version (if applicable) of this URL with [animated]. - String avatar(Snowflake id, String avatarHash, {String format = 'webp', int? size, bool animated = false}); + String avatar(Snowflake id, String avatarHash, {String format = 'webp', int? size, bool animated = true}); /// Returns URL to ``/banners/[bannerHash]``. /// With given [format], [size] and whether or not returns the animated version (if applicable) of this URL with [animated]. - String banner(Snowflake guildOrUserId, String hash, {String format = 'webp', int? size, bool animated = false}); + String banner(Snowflake guildOrUserId, String hash, {String format = 'webp', int? size, bool animated = true}); /// Returns URL to ``/channel-icons/[iconHash]``. /// With given [format] and [size]. @@ -49,11 +49,11 @@ abstract class ICdnHttpEndpoints { /// Returns URL to ``/guilds/[guildId]/users/[userId]/[avatarHash]``. /// With given [format], [size] and whether or not returns the animated version (if applicable) of this URL with [animated]. - String memberAvatar(Snowflake guildId, Snowflake userId, String avatarHash, {String format = 'webp', int? size, bool animated = false}); + String memberAvatar(Snowflake guildId, Snowflake userId, String avatarHash, {String format = 'webp', int? size, bool animated = true}); /// Returns URL tp ``/icons/[iconHash]``. /// With given [format], [size] and whether or not returns the animated version (if applicable) of this URL with [animated]. - String icon(Snowflake id, String iconHash, {String format = 'webp', int? size, bool animated = false}); + String icon(Snowflake id, String iconHash, {String format = 'webp', int? size, bool animated = true}); /// Returns URL to ``/role-icons/[roleIconHash]``. /// With given [format] and [size]. @@ -85,17 +85,13 @@ abstract class ICdnHttpEndpoints { } class CdnHttpEndpoints implements ICdnHttpEndpoints { - String _makeAnimatedCdnUrl(ICdnHttpRoute fragment, String hash, {String format = 'webp', int? size, bool animated = false}) { - if (hash.startsWith('a_') && animated) { - animated = true; - } else { - animated = false; - } + String _makeAnimatedCdnUrl(ICdnHttpRoute fragment, String hash, {String format = 'webp', int? size, bool animated = true}) { + final isAnimated = animated && hash.startsWith('a_'); - return _makeCdnUrl(fragment, format: format, size: size, animated: animated); + return _makeCdnUrl(fragment, format: format, size: size, animated: isAnimated); } - String _makeCdnUrl(ICdnHttpRoute fragments, {String format = 'webp', int? size, bool animated = false}) { + String _makeCdnUrl(ICdnHttpRoute fragments, {String format = 'webp', int? size, bool animated = true}) { if (!CdnConstants.allowedExtensions.contains(format)) { throw Exception('Invalid extension provided, must be one of ${CdnConstants.allowedExtensions.and()}; given: $format'); } @@ -136,7 +132,7 @@ class CdnHttpEndpoints implements ICdnHttpEndpoints { ); @override - String avatar(Snowflake id, String avatarHash, {String format = 'webp', int? size, bool animated = false}) => _makeAnimatedCdnUrl( + String avatar(Snowflake id, String avatarHash, {String format = 'webp', int? size, bool animated = true}) => _makeAnimatedCdnUrl( ICdnHttpRoute() ..avatars(id: id.toString()) ..addHash(hash: avatarHash), @@ -147,7 +143,7 @@ class CdnHttpEndpoints implements ICdnHttpEndpoints { ); @override - String banner(Snowflake guildOrUserId, String hash, {String format = 'webp', int? size, bool animated = false}) => _makeAnimatedCdnUrl( + String banner(Snowflake guildOrUserId, String hash, {String format = 'webp', int? size, bool animated = true}) => _makeAnimatedCdnUrl( ICdnHttpRoute() ..banners(id: guildOrUserId.toString()) ..addHash(hash: hash), @@ -185,8 +181,7 @@ class CdnHttpEndpoints implements ICdnHttpEndpoints { ); @override - String memberAvatar(Snowflake guildId, Snowflake userId, String avatarHash, {String format = 'webp', int? size, bool animated = false}) => - _makeAnimatedCdnUrl( + String memberAvatar(Snowflake guildId, Snowflake userId, String avatarHash, {String format = 'webp', int? size, bool animated = true}) => _makeAnimatedCdnUrl( ICdnHttpRoute() ..guilds(id: guildId.toString()) ..users(id: userId.toString()) @@ -202,7 +197,7 @@ class CdnHttpEndpoints implements ICdnHttpEndpoints { _makeCdnUrl(ICdnHttpRoute()..emojis(id: emojiId.toString()), format: format, size: size); @override - String icon(Snowflake id, String iconHash, {String format = 'webp', int? size, bool animated = false}) => _makeAnimatedCdnUrl( + String icon(Snowflake id, String iconHash, {String format = 'webp', int? size, bool animated = true}) => _makeAnimatedCdnUrl( ICdnHttpRoute() ..icons(id: id.toString()) ..addHash(hash: iconHash), diff --git a/lib/src/internal/interfaces/message_author.dart b/lib/src/internal/interfaces/message_author.dart index 609af4d8f..805aa791b 100644 --- a/lib/src/internal/interfaces/message_author.dart +++ b/lib/src/internal/interfaces/message_author.dart @@ -24,5 +24,5 @@ abstract class IMessageAuthor implements SnowflakeEntity { /// The user's avatar, represented as URL. /// In case if user does not have avatar, default discord avatar will be returned; [format], [size] and [animated] will no longer affectng this URL. /// If [animated] is set as `true`, if available, the url will be a gif, otherwise the [format]. - String avatarUrl({String format = 'webp', int? size, bool? animated}); + String avatarUrl({String format = 'webp', int? size, bool animated = true}); } From c7d1fa5f482ba9b9b97ab5210789b232b2348256 Mon Sep 17 00:00:00 2001 From: Szymon Uglis Date: Fri, 11 Aug 2023 22:30:38 +0200 Subject: [PATCH 3/6] bug: Error on ThreadMemberUpdateEvent due invalid event deserialization --- lib/src/events/thread_members_update_event.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/events/thread_members_update_event.dart b/lib/src/events/thread_members_update_event.dart index 6518adb3f..93cff4983 100644 --- a/lib/src/events/thread_members_update_event.dart +++ b/lib/src/events/thread_members_update_event.dart @@ -77,10 +77,12 @@ class ThreadMemberUpdateEvent implements IThreadMemberUpdateEvent { late final ThreadMember member; ThreadMemberUpdateEvent(RawApiMap raw, INyxx client) { + final data = raw["d"] as RawApiMap; + member = ThreadMember( client, - raw, - GuildCacheable(client, Snowflake(raw['guild_id'])), + data, + GuildCacheable(client, Snowflake(data['guild_id'])), ); } } From fc6537c4df038e5e1a25fe5af557344871481d52 Mon Sep 17 00:00:00 2001 From: Szymon Uglis Date: Fri, 11 Aug 2023 22:31:20 +0200 Subject: [PATCH 4/6] changelog/5.1.1 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab92cb91f..672e5e677 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 5.1.1 +__11.08.2023__ + +- bug: Error on ThreadMemberUpdateEvent due invalid event deserialization + ## 5.1.0 __16.06.2023__ From 6b634bfaaf52257ecaf9ac70828c8cd8f1862f86 Mon Sep 17 00:00:00 2001 From: Szymon Uglis Date: Fri, 11 Aug 2023 22:36:04 +0200 Subject: [PATCH 5/6] maintenance: Fix tests --- lib/src/internal/cdn_http_endpoints.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/internal/cdn_http_endpoints.dart b/lib/src/internal/cdn_http_endpoints.dart index 788c6a102..6ad8cc9ca 100644 --- a/lib/src/internal/cdn_http_endpoints.dart +++ b/lib/src/internal/cdn_http_endpoints.dart @@ -86,7 +86,7 @@ abstract class ICdnHttpEndpoints { } class CdnHttpEndpoints implements ICdnHttpEndpoints { - String _makeAnimatedCdnUrl(ICdnHttpRoute fragment, String hash, {String format = 'webp', int? size, bool animated = true}) { + String _makeAnimatedCdnUrl(ICdnHttpRoute fragment, String hash, {String format = 'webp', int? size, bool animated = false}) { final isAnimated = animated && hash.startsWith('a_'); return _makeCdnUrl(fragment, format: format, size: size, animated: isAnimated); From 0d5fd336d9e7efb905e1675b6031517e863b1346 Mon Sep 17 00:00:00 2001 From: Szymon Uglis Date: Fri, 11 Aug 2023 22:43:54 +0200 Subject: [PATCH 6/6] maintenance: Fix tests --- lib/src/internal/cdn_http_endpoints.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/internal/cdn_http_endpoints.dart b/lib/src/internal/cdn_http_endpoints.dart index 6ad8cc9ca..0ef0caf49 100644 --- a/lib/src/internal/cdn_http_endpoints.dart +++ b/lib/src/internal/cdn_http_endpoints.dart @@ -86,13 +86,13 @@ abstract class ICdnHttpEndpoints { } class CdnHttpEndpoints implements ICdnHttpEndpoints { - String _makeAnimatedCdnUrl(ICdnHttpRoute fragment, String hash, {String format = 'webp', int? size, bool animated = false}) { + String _makeAnimatedCdnUrl(ICdnHttpRoute fragment, String hash, {String format = 'webp', int? size, bool animated = true}) { final isAnimated = animated && hash.startsWith('a_'); return _makeCdnUrl(fragment, format: format, size: size, animated: isAnimated); } - String _makeCdnUrl(ICdnHttpRoute fragments, {String format = 'webp', int? size, bool animated = true}) { + String _makeCdnUrl(ICdnHttpRoute fragments, {String format = 'webp', int? size, bool animated = false}) { if (!CdnConstants.allowedExtensions.contains(format)) { throw Exception('Invalid extension provided, must be one of ${CdnConstants.allowedExtensions.and()}; given: $format'); }