Skip to content

Commit

Permalink
Merge pull request #589 from nyxx-discord/dev
Browse files Browse the repository at this point in the history
Deploy 6.0.2
  • Loading branch information
l7ssha authored Nov 16, 2023
2 parents 5fa56e8 + 752ea45 commit 61acef3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/api_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/builders/interaction_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class InteractionResponseBuilder extends CreateBuilder<InteractionResponseBuilde

factory InteractionResponseBuilder.autocompleteResult(List<CommandOptionChoiceBuilder<dynamic>> choices) => InteractionResponseBuilder(
type: InteractionCallbackType.applicationCommandAutocompleteResult,
data: choices,
data: {'choices': choices},
);

factory InteractionResponseBuilder.modal(ModalBuilder modal) => InteractionResponseBuilder(type: InteractionCallbackType.modal, data: modal);
Expand Down
24 changes: 11 additions & 13 deletions lib/src/models/interaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ mixin MessageResponse<T> on Interaction<T> {
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);
}
Expand Down Expand Up @@ -260,12 +261,12 @@ class MessageComponentInteraction extends Interaction<MessageComponentInteractio

@override
Future<void> 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;
Expand All @@ -279,14 +280,15 @@ class MessageComponentInteraction extends Interaction<MessageComponentInteractio

@override
Future<void> respond(Builder<Message> 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;
Expand All @@ -301,16 +303,12 @@ class MessageComponentInteraction extends Interaction<MessageComponentInteractio
assert(updateMessage == _didUpdateMessage || updateMessage == null, 'Cannot change the value of updateMessage between acknowledge and respond');
assert(isEphemeral == _wasEphemeral || isEphemeral == null, 'Cannot change the value of isEphemeral between acknowledge and respond');

if (_didRespond) {
throw AlreadyRespondedError(this);
}

_didRespond = true;

if (updateMessage == true) {
if (_didUpdateMessage == true) {
await manager.updateOriginalResponse(token, builder as MessageUpdateBuilder);
} else {
await manager.createFollowup(token, builder as MessageBuilder, isEphemeral: isEphemeral);
await manager.createFollowup(token, builder as MessageBuilder);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 61acef3

Please sign in to comment.