diff --git a/lib/src/classes/guild/guild.dart b/lib/src/classes/guild/guild.dart index cdfbf5e..94fabe1 100644 --- a/lib/src/classes/guild/guild.dart +++ b/lib/src/classes/guild/guild.dart @@ -3,6 +3,7 @@ import '../images/guild_icon.dart'; import '../../requests.dart'; import '../channel/channel.dart'; import '../channel/channel_manager.dart'; +import '../images/guild_splash.dart'; import '../member/member.dart'; import '../member/member_manager.dart'; import '../role/role.dart'; @@ -27,7 +28,8 @@ class Guild { late String name; // x | x | x late GuildIcon? icon; // x | x | x late String? iconHash; // x | x | - String? splash; // x | x | + String? splashHash; // x | x | + GuildSplash? splash; String? discoverySplash; // x | x | bool? appIsOwner; // | | x Future? owner; // | | @@ -93,9 +95,16 @@ class Guild { unavailable = false; name = data["name"]; - icon = GuildIcon(data["icon"], id); + if (data["icon"] != null) { + icon = GuildIcon(data["icon"], id); + } else { + icon = null; + } iconHash = data["icon_hash"]; - splash = data["splash"]; + splashHash = data["splash"]; + if (splashHash != null) { + splash = GuildSplash(splashHash.toString(), id); + } if (data["discovery_splash"] != null) { discoverySplash = data["discovery_splash"]; } else { @@ -103,7 +112,11 @@ class Guild { } appIsOwner = data["owner"]; ownerId = data["owner_id"]; - owner = members?.fetch(ownerId.toString()); + if (ownerId != null) { + owner = members?.fetch(ownerId.toString()); + } else { + owner = null; + } permissions = data["permissions"]; afkChannelId = data["afk_channel_id"]; afkTimeout = data["afk_timeout"]; diff --git a/lib/src/classes/guild/unavailable_guild.dart b/lib/src/classes/guild/unavailable_guild.dart index 733dfa1..9e777c4 100644 --- a/lib/src/classes/guild/unavailable_guild.dart +++ b/lib/src/classes/guild/unavailable_guild.dart @@ -1,13 +1,11 @@ -import '../../requests.dart'; import "guild.dart"; class UnavailableGuild { - final Sender _sender; late String id; late bool unavailable; late Guild? notUpdatedData; - UnavailableGuild(this._sender, this.id, { this.notUpdatedData }) { + UnavailableGuild(this.id, { this.notUpdatedData }) { unavailable = true; } -} \ No newline at end of file +} \ No newline at end of file diff --git a/lib/src/classes/images/guild_icon.dart b/lib/src/classes/images/guild_icon.dart index f566227..ab2c941 100644 --- a/lib/src/classes/images/guild_icon.dart +++ b/lib/src/classes/images/guild_icon.dart @@ -2,11 +2,12 @@ import 'base_image.dart'; class GuildIcon extends BaseImage { late String id; + GuildIcon(String hash, this.id) : super(hash) { this.hash = hash; } - String url(String? extension) { - return "https://cdn.discordapp.com/guild-icons/$id/$hash.$extension"; + String url({String? extension = "jpeg"}) { + return "https://cdn.discordapp.com/icons/$id/$hash.$extension"; } } \ No newline at end of file diff --git a/lib/src/classes/images/guild_splash.dart b/lib/src/classes/images/guild_splash.dart new file mode 100644 index 0000000..eb82b15 --- /dev/null +++ b/lib/src/classes/images/guild_splash.dart @@ -0,0 +1,13 @@ +import 'base_image.dart'; + +class GuildSplash extends BaseImage { + late String id; + + GuildSplash(String hash, this.id) : super(hash) { + this.hash = hash; + } + + String url({String? extension = "jpeg"}) { + return "https://cdn.discordapp.com/splashes/$id/$hash.$extension"; + } +} \ No newline at end of file diff --git a/lib/src/classes/member/member_manager.dart b/lib/src/classes/member/member_manager.dart index 4d681d1..57938ea 100644 --- a/lib/src/classes/member/member_manager.dart +++ b/lib/src/classes/member/member_manager.dart @@ -4,10 +4,10 @@ import "../../requests.dart"; class MemberManager { final Collection cache = Collection(); - String id; + String guildId; final Sender _sender; - MemberManager(this._sender, List members, this.id) { + MemberManager(this._sender, List members, this.guildId) { for (var member in members) { cache.set(member.id, member); } @@ -21,7 +21,7 @@ class MemberManager { return await fetch(id, forceFetch: true); } } else { - var res = await _sender.fetchMember(this.id, id); + var res = await _sender.fetchMember(guildId, id); cache.set(id, Member(res)); return Member(res); }