Skip to content

Commit

Permalink
Deploy 4.1.0 (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
l7ssha authored Nov 15, 2023
2 parents 4f86da1 + 1f78b91 commit b49b661
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ Please delete options that are not relevant.
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have checked my changes haven't lowered code coverage
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 4.1.0
__15.11.2023__
- Added a helper to reply to a message.
- Fixed an issue with paginating back to a page that had already been seen.

## 4.0.0
__20.10.2023__
- Fixed an issue with link formatting.
Expand Down
20 changes: 20 additions & 0 deletions lib/src/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,24 @@ import 'package:nyxx_extensions/src/channel.dart';
extension MessageUtils on Message {
/// A URL clients can visit to navigate to this message.
Future<Uri> get url async => Uri.https(manager.client.apiOptions.host, '${(await channel.get()).url.path}/$id');

/// Sends a reply to the message.
Future<Message> sendReply(MessageBuilder builder) {
final copiedBuilder = MessageBuilder(
allowedMentions: builder.allowedMentions,
attachments: builder.attachments,
components: builder.components,
content: builder.content,
embeds: builder.embeds,
nonce: builder.nonce,
replyId: id,
requireReplyToExist: builder.requireReplyToExist,
stickerIds: builder.stickerIds,
suppressEmbeds: builder.suppressEmbeds,
suppressNotifications: builder.suppressNotifications,
tts: builder.tts,
);

return channel.sendMessage(copiedBuilder);
}
}
6 changes: 6 additions & 0 deletions lib/src/pagination.dart
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,12 @@ class _PaginationState {
throw NyxxException('Cannot add pagination controls to builder: too many component rows');
}

final knownIds = {jumpToStartId, jumpToEndId, previousId, nextId};
if (builder.components?.any((row) => row.components.any((element) => element is ButtonBuilder && knownIds.contains(element.customId))) == true) {
// We've already added controls to this builder, likely when the user navigated to this page previously.
return;
}

final showJumpToEnds = options?.showJumpToEnds ?? pagination.options.showJumpToEnds ?? true;
final showPageIndex = options?.showPageIndex ?? pagination.options.showPageIndex ?? true;

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_extensions
version: 4.0.0
version: 4.1.0
description: Extensions to the Discord API provided in nyxx, including pagination support and message sanitization.
repository: https://github.com/nyxx-discord/nyxx_extensions
documentation: https://nyxx.l7ssha.xyz
Expand Down

0 comments on commit b49b661

Please sign in to comment.