This commit is contained in:
KillerBossOriginal 2023-08-07 16:43:34 +02:00
parent b20f043551
commit fbb179e803
4 changed files with 117 additions and 86 deletions

View file

@ -1,3 +1,5 @@
import '../images/guild_icon.dart';
import '../../requests.dart';
import '../channel/channel.dart';
import '../channel/channel_manager.dart';
@ -15,11 +17,16 @@ class Guild {
RoleManager? roles;
// Param guild create | fetch | fetch-servers
late String id; // x | x | x
late bool unavailable; // x | x |
String? name; // x | x | x
String? icon; // x | x | x
String? iconHash; // x | x |
/// The guild's id <br>
/// GuildCreate, GuildUpdate, GuildDelete, FetchOneGuild, FetchAllGuild
late String id;
/// Whether the guild is available to access. If it is not available, it indicates a server outage
/// GuildCreate, GuildDelete
/// FetchOneGuild, FetchAllGuild, GuildUpdate
late bool unavailable;
late String name; // x | x | x
late GuildIcon? icon; // x | x | x
late String? iconHash; // x | x |
String? splash; // x | x |
String? discoverySplash; // x | x |
bool? appIsOwner; // | | x
@ -60,9 +67,6 @@ class Guild {
Guild(this._sender, Map data) {
id = data["id"];
// Without discord outages
if (data["unavailable"] != null && !data["unavailable"]) {
if(data["channels"] != null && data["members"] != null && data["roles"] != null) {
List<Channel> cc = [];
for (var c in data["channels"]) {
@ -87,9 +91,9 @@ class Guild {
roles = RoleManager([]);
}
unavailable = data["unavailable"] ?? false;
unavailable = false;
name = data["name"];
icon = data["icon"];
icon = GuildIcon(data["icon"], id);
iconHash = data["icon_hash"];
splash = data["splash"];
if (data["discovery_splash"] != null) {
@ -134,6 +138,7 @@ class Guild {
if (data["approximate_presence_count"] != null) {
approximatePresenceCount = data["approximate_presence_count"];
}
// GuildCreate only
if (data["joined_at"] != null) {
joinedAt = data["joined_at"];
@ -144,8 +149,5 @@ class Guild {
if (data["member_count"] != null) {
memberCount = data["member_count"];
}
} else if (data["unavailable"] != null) {
unavailable = data["unavailable"];
}
}
}

View file

@ -0,0 +1,13 @@
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 }) {
unavailable = true;
}
}

View file

@ -0,0 +1,4 @@
class BaseImage {
late String hash;
BaseImage(this.hash);
}

View file

@ -0,0 +1,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";
}
}