Skip to content

Commit

Permalink
Merge branch 'next' of github.com:nyxx-discord/nyxx_extensions into f…
Browse files Browse the repository at this point in the history
…eat/pagination
  • Loading branch information
abitofevrything committed Sep 11, 2023
2 parents 650eb05 + c3243ed commit 22d4d98
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/nyxx_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export 'src/user.dart';
export 'src/sanitizer.dart';
export 'src/guild.dart';
export 'src/pagination.dart';
export 'src/channel.dart';
export 'src/message.dart';
6 changes: 6 additions & 0 deletions lib/src/channel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import 'package:nyxx/nyxx.dart';

extension ChannelUtils on Channel {
/// A URL clients can visit to navigate to this channel.
Uri get url => Uri.https(manager.client.apiOptions.host, '/channels/${this is GuildChannel ? '${(this as GuildChannel).guildId}' : '@me'}/$id');
}
3 changes: 3 additions & 0 deletions lib/src/guild.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ extension GuildExtension on Guild {
String get acronym {
return name.replaceAll(r"'s ", ' ').replaceAllMapped(RegExp(r'\w+'), (match) => match[0]![0]).replaceAll(RegExp(r'\s'), '');
}

/// A URL clients can visit to navigate to this guild.
Uri get url => Uri.https(manager.client.apiOptions.host, '/channels/$id');
}
7 changes: 7 additions & 0 deletions lib/src/message.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:nyxx/nyxx.dart';
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');
}

0 comments on commit 22d4d98

Please sign in to comment.