toJson method
Implementation
Map<String, dynamic> toJson() {
List<Map<String, dynamic>> rolesJs = [];
for (Role role in roles) {
rolesJs.add(role.toJson());
}
List<Map<String, dynamic>> emojiJs = [];
for (Emoji emoji in emojis) {
emojiJs.add(emoji.toJson());
}
List<String> featureJs = [];
for (GuildFeatures feature in features) {
featureJs.add(feature.name);
}
List<Map<String, dynamic>>? stickersJs = null;
if (stickers != null) {
stickersJs = [];
for (Sticker sticker in stickers!) {
stickersJs.add(sticker.toJson());
}
}
return {
"id": id.toString(),
"name": name,
"icon": icon ?? null,
if (icon_hash != null) "icon_hash": icon_hash,
"splash": splash ?? null,
"discovery_splash": discoverySplash ?? null,
if (owner != null) "owner": owner,
"owner_id": owner_id.toString(),
if (permissions != null) "permissions": permissions.toString(),
if (region != null) "region": region,
"afk_channel_id": afk_channel_id ?? null,
if (widgetEnabled != null) "widget_enabled": widgetEnabled,
if (widgetChannelID != null) "widget_channel_id": widgetChannelID,
"verification_level": verificationLevel,
"default_message_notifications": defaultMessageNotify,
"explicit_content_filter": explicitContentFilter,
"roles": rolesJs,
"emojis": emojiJs,
"features": featureJs,
"mfa_level": mfaLevel,
"application_id": applicationId == null ? null : applicationId.toString(),
"system_channel_id":
systemChannelId == null ? null : systemChannelId.toString(),
"system_channel_flags": systemChannelFlags,
"rules_channel_id":
rulesChannelId != null ? rulesChannelId.toString() : null,
if (maxPresences != null) "max_presences": maxPresences,
if (maxMembers != null) "max_members": maxMembers,
"vanity_url_code": vanityUrlCode,
"description": description,
"banner": banner,
"premium_tier": premiumTier,
if (premiumSubscriptionCount != null)
"premium_subscription_count": premiumSubscriptionCount,
"preferred_locale": preferredLocale,
"public_updates_channel_id": publicUpdateChannelId == null
? null
: publicUpdateChannelId.toString(),
if (maxVideoChannelUsers != null)
"max_video_channel_users": maxVideoChannelUsers,
if (maxStageVideoChannelUsers != null)
"max_stage_video_channel_users": maxStageVideoChannelUsers,
if (approximateMemberCount != null)
"approximate_member_count": approximateMemberCount,
if (approximatePresenceCount != null)
"approximate_presence_count": approximatePresenceCount,
if (welcomeScreen != null) "welcome_screen": welcomeScreen!.toJson(),
"nsfw_level": nsfwLevel,
if (stickers != null) "stickers": stickersJs,
"premium_progress_bar_enabled": premiumProgressBarEnabled,
"safety_alerts_channel_id": safetyAlertsChannelId == null
? null
: safetyAlertsChannelId.toString()
};
}