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__ diff --git a/lib/src/core/application/app_team_user.dart b/lib/src/core/application/app_team_user.dart index a02897a95..44d697bd3 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, id.id); } diff --git a/lib/src/core/guild/guild.dart b/lib/src/core/guild/guild.dart index f933d42ab..1d8f549d6 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 = 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 = false}); + 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,7 +730,7 @@ 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 = true}) { if (icon == null) { return null; } @@ -768,7 +768,7 @@ 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 = true}) { if (banner == null) { return null; } diff --git a/lib/src/core/guild/guild_preview.dart b/lib/src/core/guild/guild_preview.dart index e0e559e97..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 = false}); + 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,7 +115,7 @@ 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 = true}) { if (iconHash == null) { return null; } diff --git a/lib/src/core/guild/webhook.dart b/lib/src/core/guild/webhook.dart index 1570c34cc..4867d62bd 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 = true}); /// Edits the webhook. Future edit({String? name, SnowflakeEntity? channel, AttachmentBuilder? avatarAttachment, String? auditReason}); @@ -187,7 +187,7 @@ 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 = true}) { if (avatarHash == null) { return client.cdnHttpEndpoints.defaultAvatar(defaultAvatarId, id.id); } 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 24f8ad688..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 = false}); + 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,7 +208,7 @@ 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 = true}) { if (avatarHash == null) { return null; } diff --git a/lib/src/core/user/user.dart b/lib/src/core/user/user.dart index 2d2219390..0a76fad0d 100644 --- a/lib/src/core/user/user.dart +++ b/lib/src/core/user/user.dart @@ -55,7 +55,7 @@ abstract class IUser implements SnowflakeEntity, ISend, Mentionable, IMessageAut String? get globalName; /// The user's banner url. - String? bannerUrl({String format = 'webp', int? size, bool animated = false}); + String? bannerUrl({String format = 'webp', int? size, bool animated = true}); /// The user's avatar decoration url, if any. String? avatarDecorationUrl({int size}); @@ -181,7 +181,7 @@ 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 = true}) { if (avatar == null) { return client.cdnHttpEndpoints.defaultAvatar(discriminator, id.id); } @@ -191,7 +191,7 @@ class User extends SnowflakeEntity implements IUser { /// 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 = true}) { if (bannerHash == null) { return null; } 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'])), ); } } diff --git a/lib/src/internal/cdn_http_endpoints.dart b/lib/src/internal/cdn_http_endpoints.dart index c5d1eab20..0ef0caf49 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]. @@ -50,11 +50,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]. @@ -86,7 +86,7 @@ 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); @@ -133,7 +133,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), @@ -144,7 +144,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), @@ -187,8 +187,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()) @@ -204,7 +203,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 b7c9ff35e..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 = false}); + String avatarUrl({String format = 'webp', int? size, bool animated = true}); }