From 1deaea09d5c6fd6739c92e644e1bcb0a2adeff19 Mon Sep 17 00:00:00 2001 From: Szymon Uglis Date: Sun, 23 Jan 2022 16:07:52 +0100 Subject: [PATCH 1/5] bugfix: Properly serialize member edit payload. Fixes #291 --- lib/src/internal/http_endpoints.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/internal/http_endpoints.dart b/lib/src/internal/http_endpoints.dart index 66ffa5266..330385c58 100644 --- a/lib/src/internal/http_endpoints.dart +++ b/lib/src/internal/http_endpoints.dart @@ -865,7 +865,7 @@ class HttpEndpoints implements IHttpEndpoints { ..deaf = deaf ..channel = channel; - return executeSafe(BasicRequest("/guilds/$guildId/members/$memberId", method: "PATCH", auditLog: auditReason, body: finalBuilder)); + return executeSafe(BasicRequest("/guilds/$guildId/members/$memberId", method: "PATCH", auditLog: auditReason, body: finalBuilder.build())); } @override From fff43848d84ff0d949881ea8131648ebb1a9ada7 Mon Sep 17 00:00:00 2001 From: Szymon Uglis Date: Sun, 23 Jan 2022 16:15:34 +0100 Subject: [PATCH 2/5] bugfix: Improve shard searching mechanism. Fixes #290 --- lib/src/core/guild/guild.dart | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/src/core/guild/guild.dart b/lib/src/core/guild/guild.dart index cd0d83c7a..295975e92 100644 --- a/lib/src/core/guild/guild.dart +++ b/lib/src/core/guild/guild.dart @@ -476,10 +476,12 @@ class Guild extends SnowflakeEntity implements IGuild { throw UnsupportedError("Cannot use this property with NyxxRest"); } + final shardId = (id.id >> 22) % (client as NyxxWebsocket).shardManager.shards.length; + return (client as NyxxWebsocket).shardManager.shards.firstWhere( - (_shard) => _shard.guilds.contains(id), - orElse: throw InvalidShardException('Cannot find shard for this guild!'), - ); + (element) => element.id == shardId, + orElse: () => throw InvalidShardException('Cannot find shard for this guild! Calculated shard id for this guild is: $shardId but no such shard exist'), + ); } /// Creates an instance of [Guild] From a6318d635d193ba87d74c831e84f2e8b6b231f96 Mon Sep 17 00:00:00 2001 From: Szymon Uglis Date: Sun, 23 Jan 2022 17:12:45 +0100 Subject: [PATCH 3/5] bugfix: Fix message deserialization bug with roleMentions. Fixes #289 --- lib/src/core/message/message.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/core/message/message.dart b/lib/src/core/message/message.dart index ca31a22e3..fbed4968e 100644 --- a/lib/src/core/message/message.dart +++ b/lib/src/core/message/message.dart @@ -361,7 +361,7 @@ class Message extends SnowflakeEntity implements IMessage { } roleMentions = [ - if (raw["mention_roles"] != null) + if (raw["mention_roles"] != null && guild != null) for (var roleId in raw["mention_roles"]) RoleCacheable(client, Snowflake(roleId), guild!) ]; } From 23e5771e2dfe1bb95787d96fd708f7482f199109 Mon Sep 17 00:00:00 2001 From: Szymon Uglis Date: Sun, 23 Jan 2022 17:14:02 +0100 Subject: [PATCH 4/5] Release 3.2.4 --- CHANGELOG.md | 7 +++++++ lib/src/internal/constants.dart | 2 +- pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9f0e0cff..e11e4200f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 3.2.4 +__23.01.2022__ + +- bugfix: Properly serialize member edit payload. Fixes #291 +- bugfix: Improve shard searching mechanism. Fixes #290 +- bugfix: Fix message deserialization bug with roleMentions. Fixes #289 + ## 3.2.3 __10.01.2022__ diff --git a/lib/src/internal/constants.dart b/lib/src/internal/constants.dart index 712affdf3..5900a7105 100644 --- a/lib/src/internal/constants.dart +++ b/lib/src/internal/constants.dart @@ -33,7 +33,7 @@ class Constants { static const int apiVersion = 9; /// Version of Nyxx - static const String version = "3.2.3"; + static const String version = "3.2.4"; /// Url to Nyxx repo static const String repoUrl = "https://github.com/nyxx-discord/nyxx"; diff --git a/pubspec.yaml b/pubspec.yaml index e94e482b9..2fd60aa8c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: nyxx -version: 3.2.3 +version: 3.2.4 description: A Discord library for Dart. Simple, robust framework for creating discord bots for Dart language. homepage: https://github.com/nyxx-discord/nyxx repository: https://github.com/nyxx-discord/nyxx From f05ee71976a0d85ab34db80eb06840168158866b Mon Sep 17 00:00:00 2001 From: Szymon Uglis Date: Sun, 23 Jan 2022 17:45:56 +0100 Subject: [PATCH 5/5] Fix formatting --- lib/src/core/guild/guild.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/src/core/guild/guild.dart b/lib/src/core/guild/guild.dart index 295975e92..8ad9f387c 100644 --- a/lib/src/core/guild/guild.dart +++ b/lib/src/core/guild/guild.dart @@ -479,9 +479,10 @@ class Guild extends SnowflakeEntity implements IGuild { final shardId = (id.id >> 22) % (client as NyxxWebsocket).shardManager.shards.length; return (client as NyxxWebsocket).shardManager.shards.firstWhere( - (element) => element.id == shardId, - orElse: () => throw InvalidShardException('Cannot find shard for this guild! Calculated shard id for this guild is: $shardId but no such shard exist'), - ); + (element) => element.id == shardId, + orElse: () => + throw InvalidShardException('Cannot find shard for this guild! Calculated shard id for this guild is: $shardId but no such shard exist'), + ); } /// Creates an instance of [Guild]