Updating Guild

This commit is contained in:
KillerBossOrig 2023-08-07 12:34:29 +02:00
parent 0d7c0bbd7d
commit b20f043551
4 changed files with 39 additions and 8 deletions

View file

@ -39,8 +39,21 @@ class Guild {
String? systemChannelId; // x | x |
int? systemChannelFlags; // x | x |
String? rulesChannelId; // x | x |
String? description;
int? maxPresences; // x | x |
int? maxMembers; // x | x |
String? vanityUrlCode; // x | x |
String? description; // x | x |
String? banner; // x | x |
int? premiumTier; // x | x |
int? premiumSubscriptionCount; // x | x |
String? preferredLocale; // x | x |
String? publicUpdatesChannelId; // x | x |
int? maxVideoChannelUsers; // x | x |
int? maxStageVideoChannelUsers; // | x | x
int? approximateMemberCount; // | x | x
int? approximatePresenceCount; // | x | x
bool? premiumProgressBarEnabled;// x | x |
String? safetyAlertsChannelId; // x | x |
String? joinedAt; // x | |
bool? large; // x | |
int? memberCount; // x | |
@ -101,8 +114,26 @@ class Guild {
systemChannelId = data["system_channel_id"];
systemChannelFlags = data["system_channel_flags"];
rulesChannelId = data["rules_channel_id"];
maxPresences = data["max_presences"];
maxMembers = data["max_members"];
vanityUrlCode = data["vanity_url_code"];
description = data["description"];
banner = data["banner"];
premiumTier = data["premium_tier"];
premiumSubscriptionCount = data["premium_subscription_count"];
preferredLocale = data["preferred_locale"];
publicUpdatesChannelId = data["public_updates_channel_id"];
maxVideoChannelUsers = data["max_video_channel_users"];
maxStageVideoChannelUsers = data["max_stage_video_channel_users"];
premiumProgressBarEnabled = data["premium_progress_bar_enabled"];
safetyAlertsChannelId = data["safety_alerts_channel_id"];
if (data["approximate_member_count"] != null) {
approximateMemberCount = data["approximate_member_count"];
}
if (data["approximate_presence_count"] != null) {
approximatePresenceCount = data["approximate_presence_count"];
}
// GuildCreate only
if (data["joined_at"] != null) {
joinedAt = data["joined_at"];

View file

@ -13,7 +13,7 @@ class GuildManager {
}
Future<Guild> fetch(String id) async {
var res = await _sender.fetchGuild(id);
var res = await _sender.fetchGuild(id, withCounts: true);
final guild = Guild(_sender, res);
Guild oldGuild = cache.get(guild.id);
oldGuild.members?.cache.values().forEach((member) {

View file

@ -85,7 +85,7 @@ class Client extends EventEmitter {
}
Sender sender = Sender(token);
var i = await sender.getServers();
var i = await sender.fetchGuilds(withCounts: true);
List<Guild> gg = [];

View file

@ -45,8 +45,8 @@ class Sender {
};
}
Future getServers() async {
final url = Uri.parse("$apiURL/users/@me/guilds");
Future fetchGuilds({ bool withCounts = false }) async {
final url = Uri.parse("$apiURL/users/@me/guilds?with_counts=$withCounts");
dynamic res = await http.get(url, headers: headers);
res = json.decode(res.body);
return res;
@ -59,8 +59,8 @@ class Sender {
return res;
}
Future fetchGuild(String id) async {
dynamic res = await http.get(Uri.parse("$apiURL/guilds/$id"), headers: headers);
Future fetchGuild(String id, { bool withCounts = false }) async {
dynamic res = await http.get(Uri.parse("$apiURL/guilds/$id?with_counts=$withCounts"), headers: headers);
if (res.statusCode != 200) {
throw Exception("Error ${res.statusCode} receiving the guild");
}