Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
l7ssha committed Aug 11, 2023
2 parents a928e2b + 36debe8 commit b89952b
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 29 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 5.1.1
__11.08.2023__

- bug: Error on ThreadMemberUpdateEvent due invalid event deserialization

## 5.1.0
__16.06.2023__

Expand Down
2 changes: 1 addition & 1 deletion lib/src/core/application/app_team_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class AppTeamUser extends SnowflakeEntity implements IAppTeamUser {
}

@override
String avatarUrl({String format = 'webp', int? size, bool animated = false}) {
String avatarUrl({String format = 'webp', int? size, bool animated = true}) {
if (avatar == null) {
return client.cdnHttpEndpoints.defaultAvatar(int.tryParse(discriminator) ?? 0, id.id);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/src/core/guild/guild.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ abstract class IGuild implements SnowflakeEntity {

/// The guild's icon, represented as URL.
/// If guild doesn't have icon it returns null.
String? iconUrl({String format = 'webp', int? size, bool animated = false});
String? iconUrl({String format = 'webp', int? size, bool animated = true});

/// URL to guild's splash.
/// If guild doesn't have splash it returns null.
Expand All @@ -211,7 +211,7 @@ abstract class IGuild implements SnowflakeEntity {

/// URL to guild's banner.
/// If guild doesn't have banner it returns null.
String? bannerUrl({String format = 'webp', int? size, bool animated = false});
String? bannerUrl({String format = 'webp', int? size, bool animated = true});

/// Allows to download [IGuild] widget aka advert png
/// Possible options for [style]: shield (default), banner1, banner2, banner3, banner4
Expand Down Expand Up @@ -730,7 +730,7 @@ class Guild extends SnowflakeEntity implements IGuild {
/// The guild's icon, represented as URL.
/// If guild doesn't have icon it returns null.
@override
String? iconUrl({String format = 'webp', int? size, bool animated = false}) {
String? iconUrl({String format = 'webp', int? size, bool animated = true}) {
if (icon == null) {
return null;
}
Expand Down Expand Up @@ -768,7 +768,7 @@ class Guild extends SnowflakeEntity implements IGuild {
/// Returns the URL to guild's banner.
/// If guild doesn't have banner it returns null.
@override
String? bannerUrl({String format = 'webp', int? size, bool animated = false}) {
String? bannerUrl({String format = 'webp', int? size, bool animated = true}) {
if (banner == null) {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/core/guild/guild_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ abstract class IGuildPreview implements SnowflakeEntity {

/// The guild's icon, represented as URL.
/// If guild doesn't have icon it returns null.
String? iconUrl({String format = 'webp', int? size, bool animated = false});
String? iconUrl({String format = 'webp', int? size, bool animated = true});

/// URL to guild's splash.
/// If guild doesn't have splash it returns null.
Expand Down Expand Up @@ -115,7 +115,7 @@ class GuildPreview extends SnowflakeEntity implements IGuildPreview {
/// The guild's icon, represented as URL.
/// If guild doesn't have icon it returns null.
@override
String? iconUrl({String format = 'webp', int? size, bool animated = false}) {
String? iconUrl({String format = 'webp', int? size, bool animated = true}) {
if (iconHash == null) {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/core/guild/webhook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ abstract class IWebhook implements SnowflakeEntity, IMessageAuthor {
Future<IMessage?> execute(MessageBuilder builder, {bool wait = true, Snowflake? threadId, String? threadName, String? avatarUrl, String? username});

@override
String avatarUrl({String format = 'webp', int? size, bool animated = false});
String avatarUrl({String format = 'webp', int? size, bool animated = true});

/// Edits the webhook.
Future<IWebhook> edit({String? name, SnowflakeEntity? channel, AttachmentBuilder? avatarAttachment, String? auditReason});
Expand Down Expand Up @@ -187,7 +187,7 @@ class Webhook extends SnowflakeEntity implements IWebhook {
.executeWebhook(id, builder, token: token, threadId: threadId, username: username, wait: wait, avatarUrl: avatarUrl, threadName: threadName);

@override
String avatarUrl({String format = 'webp', int? size, bool animated = false}) {
String avatarUrl({String format = 'webp', int? size, bool animated = true}) {
if (avatarHash == null) {
return client.cdnHttpEndpoints.defaultAvatar(defaultAvatarId, id.id);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/core/message/guild_emoji.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract class IBaseGuildEmoji implements SnowflakeEntity, IEmoji {

/// Returns the CDN URL for this emoji with given [format] and [size].
/// If [animated] is set as `true`, an animated version of the emoji (if applicable) will be displayed.
String cdnUrl({String format = 'webp', int? size, bool animated = false});
String cdnUrl({String format = 'webp', int? size, bool animated = true});
}

abstract class BaseGuildEmoji extends SnowflakeEntity implements IBaseGuildEmoji {
Expand All @@ -50,7 +50,7 @@ abstract class BaseGuildEmoji extends SnowflakeEntity implements IBaseGuildEmoji

/// Returns cdn url to emoji
@override
String cdnUrl({String format = 'webp', int? size, bool animated = false}) {
String cdnUrl({String format = 'webp', int? size, bool animated = true}) {
return client.cdnHttpEndpoints.emoji(id, format: this.animated && animated ? 'gif' : format, size: size);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/src/core/user/member.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ abstract class IMember implements SnowflakeEntity, Mentionable {

/// The member's avatar, represented as URL. With given [format] and [size].
/// If [animated] is set as `true`, if available, the url will be a gif, otherwise the [format] or fallback to "webp".
String? avatarUrl({String format = 'webp', int? size, bool animated = false});
String? avatarUrl({String format = 'webp', int? size, bool animated = true});

/// Bans the member and optionally deletes [deleteMessageDays] days worth of messages.
Future<void> ban({int? deleteMessageDays, String? reason, String? auditReason});
Expand Down Expand Up @@ -208,7 +208,7 @@ class Member extends SnowflakeEntity implements IMember {

/// Returns url to member avatar
@override
String? avatarUrl({String format = 'webp', int? size, bool animated = false}) {
String? avatarUrl({String format = 'webp', int? size, bool animated = true}) {
if (avatarHash == null) {
return null;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/src/core/user/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ abstract class IUser implements SnowflakeEntity, ISend, Mentionable, IMessageAut
String? get globalName;

/// The user's banner url.
String? bannerUrl({String format = 'webp', int? size, bool animated = false});
String? bannerUrl({String format = 'webp', int? size, bool animated = true});

/// The user's avatar decoration url, if any.
String? avatarDecorationUrl({int size});
Expand Down Expand Up @@ -181,7 +181,7 @@ class User extends SnowflakeEntity implements IUser {
/// The user's avatar, represented as URL.
/// In case if user does not have avatar, default discord avatar will be returned with specified size and png format.
@override
String avatarUrl({String format = 'webp', int? size, bool animated = false}) {
String avatarUrl({String format = 'webp', int? size, bool animated = true}) {
if (avatar == null) {
return client.cdnHttpEndpoints.defaultAvatar(discriminator, id.id);
}
Expand All @@ -191,7 +191,7 @@ class User extends SnowflakeEntity implements IUser {

/// The user's banner url.
@override
String? bannerUrl({String format = 'webp', int? size, bool animated = false}) {
String? bannerUrl({String format = 'webp', int? size, bool animated = true}) {
if (bannerHash == null) {
return null;
}
Expand Down
6 changes: 4 additions & 2 deletions lib/src/events/thread_members_update_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ class ThreadMemberUpdateEvent implements IThreadMemberUpdateEvent {
late final ThreadMember member;

ThreadMemberUpdateEvent(RawApiMap raw, INyxx client) {
final data = raw["d"] as RawApiMap;

member = ThreadMember(
client,
raw,
GuildCacheable(client, Snowflake(raw['guild_id'])),
data,
GuildCacheable(client, Snowflake(data['guild_id'])),
);
}
}
19 changes: 9 additions & 10 deletions lib/src/internal/cdn_http_endpoints.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ abstract class ICdnHttpEndpoints {

/// Returns URL to ``/avatars/[avatarHash]``.
/// With given [format], [size] and whether or not returns the animated version (if applicable) of this URL with [animated].
String avatar(Snowflake id, String avatarHash, {String format = 'webp', int? size, bool animated = false});
String avatar(Snowflake id, String avatarHash, {String format = 'webp', int? size, bool animated = true});

/// Returns URL to ``/banners/[bannerHash]``.
/// With given [format], [size] and whether or not returns the animated version (if applicable) of this URL with [animated].
String banner(Snowflake guildOrUserId, String hash, {String format = 'webp', int? size, bool animated = false});
String banner(Snowflake guildOrUserId, String hash, {String format = 'webp', int? size, bool animated = true});

/// Returns URL to ``/channel-icons/[iconHash]``.
/// With given [format] and [size].
Expand All @@ -50,11 +50,11 @@ abstract class ICdnHttpEndpoints {

/// Returns URL to ``/guilds/[guildId]/users/[userId]/[avatarHash]``.
/// With given [format], [size] and whether or not returns the animated version (if applicable) of this URL with [animated].
String memberAvatar(Snowflake guildId, Snowflake userId, String avatarHash, {String format = 'webp', int? size, bool animated = false});
String memberAvatar(Snowflake guildId, Snowflake userId, String avatarHash, {String format = 'webp', int? size, bool animated = true});

/// Returns URL tp ``/icons/[iconHash]``.
/// With given [format], [size] and whether or not returns the animated version (if applicable) of this URL with [animated].
String icon(Snowflake id, String iconHash, {String format = 'webp', int? size, bool animated = false});
String icon(Snowflake id, String iconHash, {String format = 'webp', int? size, bool animated = true});

/// Returns URL to ``/role-icons/[roleIconHash]``.
/// With given [format] and [size].
Expand Down Expand Up @@ -86,7 +86,7 @@ abstract class ICdnHttpEndpoints {
}

class CdnHttpEndpoints implements ICdnHttpEndpoints {
String _makeAnimatedCdnUrl(ICdnHttpRoute fragment, String hash, {String format = 'webp', int? size, bool animated = false}) {
String _makeAnimatedCdnUrl(ICdnHttpRoute fragment, String hash, {String format = 'webp', int? size, bool animated = true}) {
final isAnimated = animated && hash.startsWith('a_');

return _makeCdnUrl(fragment, format: format, size: size, animated: isAnimated);
Expand Down Expand Up @@ -133,7 +133,7 @@ class CdnHttpEndpoints implements ICdnHttpEndpoints {
);

@override
String avatar(Snowflake id, String avatarHash, {String format = 'webp', int? size, bool animated = false}) => _makeAnimatedCdnUrl(
String avatar(Snowflake id, String avatarHash, {String format = 'webp', int? size, bool animated = true}) => _makeAnimatedCdnUrl(
ICdnHttpRoute()
..avatars(id: id.toString())
..addHash(hash: avatarHash),
Expand All @@ -144,7 +144,7 @@ class CdnHttpEndpoints implements ICdnHttpEndpoints {
);

@override
String banner(Snowflake guildOrUserId, String hash, {String format = 'webp', int? size, bool animated = false}) => _makeAnimatedCdnUrl(
String banner(Snowflake guildOrUserId, String hash, {String format = 'webp', int? size, bool animated = true}) => _makeAnimatedCdnUrl(
ICdnHttpRoute()
..banners(id: guildOrUserId.toString())
..addHash(hash: hash),
Expand Down Expand Up @@ -187,8 +187,7 @@ class CdnHttpEndpoints implements ICdnHttpEndpoints {
);

@override
String memberAvatar(Snowflake guildId, Snowflake userId, String avatarHash, {String format = 'webp', int? size, bool animated = false}) =>
_makeAnimatedCdnUrl(
String memberAvatar(Snowflake guildId, Snowflake userId, String avatarHash, {String format = 'webp', int? size, bool animated = true}) => _makeAnimatedCdnUrl(
ICdnHttpRoute()
..guilds(id: guildId.toString())
..users(id: userId.toString())
Expand All @@ -204,7 +203,7 @@ class CdnHttpEndpoints implements ICdnHttpEndpoints {
_makeCdnUrl(ICdnHttpRoute()..emojis(id: emojiId.toString()), format: format, size: size);

@override
String icon(Snowflake id, String iconHash, {String format = 'webp', int? size, bool animated = false}) => _makeAnimatedCdnUrl(
String icon(Snowflake id, String iconHash, {String format = 'webp', int? size, bool animated = true}) => _makeAnimatedCdnUrl(
ICdnHttpRoute()
..icons(id: id.toString())
..addHash(hash: iconHash),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/internal/interfaces/message_author.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ abstract class IMessageAuthor implements SnowflakeEntity {
/// The user's avatar, represented as URL.
/// In case if user does not have avatar, default discord avatar will be returned; [format], [size] and [animated] will no longer affectng this URL.
/// If [animated] is set as `true`, if available, the url will be a gif, otherwise the [format].
String avatarUrl({String format = 'webp', int? size, bool animated = false});
String avatarUrl({String format = 'webp', int? size, bool animated = true});
}

0 comments on commit b89952b

Please sign in to comment.