From 55a8c760b3a2cf0b481a3e7b941c9b9fe62cc359 Mon Sep 17 00:00:00 2001 From: Abitofevrything <54505189+abitofevrything@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:12:57 +0100 Subject: [PATCH 1/3] Fix autocompletion interaction responses (#585) --- lib/src/builders/interaction_response.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/builders/interaction_response.dart b/lib/src/builders/interaction_response.dart index 1b9efdc7e..b0263949f 100644 --- a/lib/src/builders/interaction_response.dart +++ b/lib/src/builders/interaction_response.dart @@ -49,7 +49,7 @@ class InteractionResponseBuilder extends CreateBuilder> choices) => InteractionResponseBuilder( type: InteractionCallbackType.applicationCommandAutocompleteResult, - data: choices, + data: {'choices': choices}, ); factory InteractionResponseBuilder.modal(ModalBuilder modal) => InteractionResponseBuilder(type: InteractionCallbackType.modal, data: modal); From f7abb730c501bd744a10cf79ff1b92c86be9e9ac Mon Sep 17 00:00:00 2001 From: Abitofevrything <54505189+abitofevrything@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:13:18 +0100 Subject: [PATCH 2/3] Correct assertions in interaction.respond (#584) --- lib/src/models/interaction.dart | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/src/models/interaction.dart b/lib/src/models/interaction.dart index bb0b407b7..fbcd5400a 100644 --- a/lib/src/models/interaction.dart +++ b/lib/src/models/interaction.dart @@ -133,6 +133,7 @@ mixin MessageResponse on Interaction { await manager.createResponse(id, token, InteractionResponseBuilder.channelMessage(builder, isEphemeral: isEphemeral)); } else { assert(isEphemeral == _wasEphemeral || isEphemeral == null, 'Cannot change the value of isEphemeral between acknowledge and respond'); + _didRespond = true; await manager.createFollowup(token, builder); } @@ -260,12 +261,12 @@ class MessageComponentInteraction extends Interaction acknowledge({bool? updateMessage, bool? isEphemeral}) async { + assert(updateMessage != true || isEphemeral != true, 'Cannot set isEphemeral to true if updateMessage is set to true'); + if (_didAcknowledge) { throw AlreadyAcknowledgedError(this); } - assert(updateMessage != true || isEphemeral != true, 'Cannot set isEphemeral to true if updateMessage is set to true'); - _didAcknowledge = true; _didUpdateMessage = updateMessage; _wasEphemeral = isEphemeral; @@ -279,14 +280,15 @@ class MessageComponentInteraction extends Interaction respond(Builder builder, {bool? updateMessage, bool? isEphemeral}) async { - assert(updateMessage == null || type == InteractionType.messageComponent, 'Cannot set updateMessage for non-component interactions'); assert(updateMessage != true || isEphemeral != true, 'Cannot set isEphemeral to true if updateMessage is set to true'); - assert(builder is MessageUpdateBuilder == updateMessage, 'builder must be a MessageUpdateBuilder if updateMessage is true'); - assert(builder is MessageBuilder != updateMessage, 'builder must be a MessageBuilder if updateMessage is null or false'); + assert(updateMessage != true || builder is MessageUpdateBuilder, 'builder must be a MessageUpdateBuilder if updateMessage is true'); + assert(updateMessage == true || builder is MessageBuilder, 'builder must be a MessageBuilder if updateMessage is null or false'); - if (!_didAcknowledge) { - assert(updateMessage != true || isEphemeral != true, 'Cannot set isEphemeral to true if updateMessage is set to true'); + if (_didRespond) { + throw AlreadyRespondedError(this); + } + if (!_didAcknowledge) { _didAcknowledge = true; _didRespond = true; _didUpdateMessage = updateMessage; @@ -301,16 +303,12 @@ class MessageComponentInteraction extends Interaction Date: Thu, 16 Nov 2023 18:02:57 +0100 Subject: [PATCH 3/3] Release 6.0.2 (#588) --- CHANGELOG.md | 8 +++++++- lib/src/api_options.dart | 2 +- pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da26c8d96..460d5d640 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ +## 6.0.2 +__16.11.2023__ + +- bug: Fix incorrect assertions in interaction.respond +- bug: Fix incorrect serialization of autocompletion interaction responses + ## 6.0.1 -__01.10.2023__ +__01.11.2023__ - bug: Fix incorrect serialization of CommandOptionBuilder. - bug: Fix customId missing from ButtonBuilder constructor. diff --git a/lib/src/api_options.dart b/lib/src/api_options.dart index 679a7287e..48ee92b0a 100644 --- a/lib/src/api_options.dart +++ b/lib/src/api_options.dart @@ -6,7 +6,7 @@ import 'package:oauth2/oauth2.dart'; /// Options for connecting to the Discord API. abstract class ApiOptions { /// The version of nyxx used in [defaultUserAgent]. - static const nyxxVersion = '6.0.1'; + static const nyxxVersion = '6.0.2'; /// The URL to the nyxx repository used in [defaultUserAgent]. static const nyxxRepositoryUrl = 'https://github.com/nyxx-discord/nyxx'; diff --git a/pubspec.yaml b/pubspec.yaml index 345846332..715f26c8d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: nyxx -version: 6.0.1 +version: 6.0.2 description: A complete, robust and efficient wrapper around Discord's API for bots & applications. homepage: https://github.com/nyxx-discord/nyxx repository: https://github.com/nyxx-discord/nyxx