Skip to content

Commit

Permalink
Restructure nyxx_extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
abitofevrything committed Feb 19, 2024
1 parent c18a053 commit b0f5b69
Show file tree
Hide file tree
Showing 29 changed files with 489 additions and 388 deletions.
39 changes: 27 additions & 12 deletions lib/nyxx_extensions.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
/// Extensions and additional utilities for working with [nyxx](https://pub.dev/packages/nyxx).
library nyxx_extensions;

export 'src/channel.dart';
export 'src/date_time.dart';
export 'src/embed_builder.dart';
export 'src/emoji.dart';
export 'src/guild.dart';
export 'src/message.dart';
export 'src/pagination.dart';
export 'src/role.dart';
export 'src/sanitizer.dart';
export 'src/user.dart';
export 'src/utils/emoji.dart';
export 'src/utils/endpoint_paginator.dart' hide streamPaginatedEndpoint;
export 'src/utils/formatters.dart';
export 'src/permissions.dart';
export 'src/endpoint_paginator.dart';
export 'src/utils/pagination.dart';
export 'src/utils/permissions.dart';
export 'src/utils/sanitizer.dart';

export 'src/extensions/channel.dart';
export 'src/extensions/client.dart';
export 'src/extensions/date_time.dart';
export 'src/extensions/embed.dart';
export 'src/extensions/emoji.dart';
export 'src/extensions/guild.dart';
export 'src/extensions/managers/audit_log_manager.dart';
export 'src/extensions/managers/channel_manager.dart';
export 'src/extensions/managers/entitlement_manager.dart';
export 'src/extensions/managers/guild_manager.dart';
export 'src/extensions/managers/member_manager.dart';
export 'src/extensions/managers/message_manager.dart';
export 'src/extensions/managers/scheduled_event_manager.dart';
export 'src/extensions/managers/user_manager.dart';
export 'src/extensions/member.dart';
export 'src/extensions/message.dart';
export 'src/extensions/role.dart';
export 'src/extensions/scheduled_event.dart';
export 'src/extensions/snowflake_entity.dart';
export 'src/extensions/user.dart';
12 changes: 0 additions & 12 deletions lib/src/channel.dart

This file was deleted.

298 changes: 0 additions & 298 deletions lib/src/endpoint_paginator.dart

This file was deleted.

33 changes: 33 additions & 0 deletions lib/src/extensions/channel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:nyxx/nyxx.dart';
import 'package:nyxx_extensions/src/extensions/managers/channel_manager.dart';
import 'package:nyxx_extensions/src/utils/formatters.dart';
import 'package:nyxx_extensions/src/utils/permissions.dart';

/// Extensions on [PartialChannel]s.
extension PartialChannelExtensions on PartialChannel {
/// A mention of this channel.
String get mention => channelMention(id);
}

/// Extensions on [Channel]s.
extension ChannelExtensions 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');
}

/// Extensions on [GuildChannel]s.
extension GuildChannelExtensions on GuildChannel {
/// Compute [member]'s permissions in this channel.
///
/// {@macro compute_permissions_detail}
Future<Permissions> computePermissionsFor(PartialMember member) async => await computePermissions(this, await member.get());
}

/// Extensions on [Thread]s.
extension ThreadExtensions on Thread {
/// Same as [listThreadMembers], but has no limit on the number of members returned.
///
/// {@macro paginated_endpoint_streaming_parameters}
Stream<ThreadMember> streamThreadMembers({bool? withMembers, Snowflake? after, Snowflake? before, int? pageSize}) =>
manager.streamThreadMembers(id, withMembers: withMembers, after: after, before: before, pageSize: pageSize);
}
Loading

0 comments on commit b0f5b69

Please sign in to comment.