Skip to content

Commit

Permalink
What the sigma?
Browse files Browse the repository at this point in the history
  • Loading branch information
Lexedia committed Nov 27, 2024
1 parent 8db5bf6 commit ac25dd2
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 102 deletions.
29 changes: 0 additions & 29 deletions lib/src/extensions/activity.dart

This file was deleted.

9 changes: 0 additions & 9 deletions lib/src/extensions/application.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:nyxx/nyxx.dart';
import 'package:nyxx_extensions/src/extensions/cdn_asset.dart';

/// Extensions on [PartialApplication]s.
extension PartialApplicationExtensions on PartialApplication {
Expand All @@ -22,11 +21,3 @@ extension PartialApplicationExtensions on PartialApplication {
},
);
}

extension ApplicationExtensions on Application {
/// The URL of this application's icon image.
Uri? iconUrl({CdnFormat? format, int? size}) => icon?.get(format: format, size: size);

/// The URL of this application's cover image.
Uri? coverUrl({CdnFormat? format, int? size}) => coverImage?.get(format: format, size: size);
}
20 changes: 1 addition & 19 deletions lib/src/extensions/guild.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:nyxx/nyxx.dart';
import 'package:nyxx_extensions/src/extensions/managers/guild_manager.dart';
import 'package:nyxx_extensions/src/extensions/cdn_asset.dart';

/// Extensions on [PartialGuild]s.
extension PartialGuildExtensions on PartialGuild {
Expand All @@ -14,27 +13,10 @@ extension PartialGuildExtensions on PartialGuild {

/// Return a list of channels in the client's cache that are in this guild.
List<GuildChannel> get cachedChannels => manager.client.channels.cache.values.whereType<GuildChannel>().where((element) => element.guildId == id).toList();

/// The date this guild was created at.
DateTime get createdAt => id.timestamp;
}

/// Extensions on [Guild]s.
extension GuildExtensions on Guild {
/// The acronym of the guild if no icon is chosen.
String get acronym {
return name.replaceAll(r"'s ", ' ').replaceAllMapped(RegExp(r'\w+'), (match) => match[0]![0]).replaceAll(RegExp(r'\s'), '');
}

/// The URL of this guild's icon image.
Uri? iconUrl({CdnFormat? format, int? size}) => icon?.get(format: format, size: size);

/// The URL of this guild's banner image.
Uri? bannerUrl({CdnFormat? format, int? size}) => banner?.get(format: format, size: size);

/// The URL of this guild's splash image.
Uri? splashUrl({CdnFormat? format, int? size}) => splash?.get(format: format, size: size);

/// The URL of this guild's discovery splash image.
Uri? discoverySplashUrl({CdnFormat? format, int? size}) => discoverySplash?.get(format: format, size: size);
String get acronym => name.replaceAll(r"'s ", ' ').replaceAllMapped(RegExp(r'\w+'), (match) => match[0]![0]).replaceAll(RegExp(r'\s'), '');
}
6 changes: 0 additions & 6 deletions lib/src/extensions/member.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ extension PartialMemberExtensions on PartialMember {
}

extension MemberExtensions on Member {
/// The URL of this member's avatar image.
Uri? avatarUrl({CdnFormat? format, int? size}) => avatar?.get(format: format, size: size);

/// The URL of this member's banner image.
Uri? bannerUrl({CdnFormat? format, int? size}) => banner?.get(format: format, size: size);

/// The URL of this member's avatar decoration.
// Same as in UserExtensions.
Uri? get avatarDecorationUrl => avatarDecoration?.get(format: CdnFormat.png);
Expand Down
8 changes: 3 additions & 5 deletions lib/src/extensions/message.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import 'package:nyxx/nyxx.dart';
import 'package:nyxx_extensions/nyxx_extensions.dart';

extension PartialMessageExtensions on PartialMessage {
/// The time this message was sent at.
DateTime get createdAt => id.timestamp;
}

/// Extensions on [Message]s.
extension MessageExtensions on Message {
/// A URL clients can visit to navigate to this message.
Expand All @@ -26,6 +21,9 @@ extension MessageExtensions on Message {
suppressEmbeds: builder.suppressEmbeds,
suppressNotifications: builder.suppressNotifications,
tts: builder.tts,
enforceNonce: builder.enforceNonce,
poll: builder.poll,
referencedMessage: builder.referencedMessage,
);

return channel.sendMessage(copiedBuilder);
Expand Down
9 changes: 0 additions & 9 deletions lib/src/extensions/role.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:nyxx/nyxx.dart';
import 'package:nyxx_extensions/src/utils/formatters.dart';
import 'package:nyxx_extensions/src/extensions/cdn_asset.dart';

/// Extensions on [PartialRole]s.
extension PartialRoleExtensions on PartialRole {
Expand All @@ -12,9 +11,6 @@ extension PartialRoleExtensions on PartialRole {

return roleMention(id);
}

/// The date this role was created at.
DateTime get createdAt => id.timestamp;
}

/// Extensions on [List]s of [Role]s.
Expand All @@ -33,8 +29,3 @@ extension RoleList on List<Role> {
/// The roles in this list, sorted from lowest to highest.
List<Role> get sorted => List.of(this)..sort(compare);
}

extension RoleExtensions on Role {
/// The URL of this role's icon image.
Uri? iconUrl({CdnFormat? format, int? size}) => icon?.get(format: format, size: size);
}
6 changes: 0 additions & 6 deletions lib/src/extensions/scheduled_event.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:nyxx/nyxx.dart';
import 'package:nyxx_extensions/src/extensions/managers/scheduled_event_manager.dart';
import 'package:nyxx_extensions/src/utils/endpoint_paginator.dart';
import 'package:nyxx_extensions/src/extensions/cdn_asset.dart';

/// Extensions on [PartialScheduledEvent].
extension PartialScheduledEventExtensions on PartialScheduledEvent {
Expand All @@ -26,8 +25,3 @@ extension PartialScheduledEventExtensions on PartialScheduledEvent {
withMembers: withMembers,
);
}

extension ScheduledEventExtensions on ScheduledEvent {
/// The URL of this event's icon image.
Uri? coverUrl({CdnFormat? format, int? size}) => coverImage?.get(format: format, size: size);
}
3 changes: 3 additions & 0 deletions lib/src/extensions/snowflake_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ extension SnowflakeEntityExtensions<T extends SnowflakeEntity<T>> on SnowflakeEn
return null;
}
}

/// The date and time this entity was created.
DateTime get createdAt => id.timestamp;
}

/// Extensions on [ManagedSnowflakeEntity]s.
Expand Down
7 changes: 0 additions & 7 deletions lib/src/extensions/team.dart

This file was deleted.

12 changes: 0 additions & 12 deletions lib/src/extensions/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,12 @@ extension PartialUserExtensions on PartialUser {

/// A mention of this user.
String get mention => userMention(id);

/// Returns when the user was created.
DateTime get createdAt => id.timestamp;
}

extension UserExtensions on User {
/// The user's unique username, if migrated, else a combination of their username and discriminator.
String get tag => discriminator == '0' ? username : '$username#$discriminator';

/// The URL of this user's avatar image.
Uri avatarUrl({CdnFormat? format, int? size}) => avatar.get(format: format, size: size);

/// The URL of this user's banner image.
Uri? bannerUrl({CdnFormat? format, int? size}) => banner?.get(format: format, size: size);

/// The URL of this user's default avatar image.
Uri get defaultAvatarUrl => defaultAvatar.url;

/// The URL of this user's avatar decoration.
// Forcefully add the `.png` extension, otherwise it's converted as a GIF if the hash starts with `a_`, and GIFs are not supported.
Uri? get avatarDecorationUrl => avatarDecoration?.get(format: CdnFormat.png);
Expand Down

0 comments on commit ac25dd2

Please sign in to comment.