Guild.decode constructor
Implementation
factory Guild.decode(Map<String, dynamic> js) {
List<Role> JsRoles = [];
List<Map<String, dynamic>> rolesJs =
js['roles'] as List<Map<String, dynamic>>;
for (var entry in rolesJs) {
JsRoles.add(Role.decode(entry));
}
List<Emoji> JsEmoji = [];
for (var entry in js['emojis'] as List<Map<String, dynamic>>) {
JsEmoji.add(Emoji.decode(entry));
}
List<GuildFeatures> JsFeatures = [];
for (var entry in js['features'] as List<String>) {
GuildFeatures? gf = GuildFeatures.byName(entry);
if (gf != null) JsFeatures.add(gf);
}
List<Sticker>? JsSStickers = null;
if (js.containsKey("stickers")) {
JsSStickers = [];
for (var entry in js['stickers'] as List<Map<String, dynamic>>) {
JsSStickers.add(Sticker.decode(entry));
}
}
return Guild(
id: Snowflake.parse(js['id'], Snowflake.DiscordEpoch),
name: js['name'],
icon: js['icon'],
icon_hash: setor(js, "icon_hash", null),
splash: js['splash'],
discoverySplash: js['discovery_splash'],
permissions: js.containsKey("permissions")
? BitMask.of(int.parse(js['permissions']))
: null,
owner_id: Snowflake.parse(js['owner_id'], Snowflake.DiscordEpoch),
afk_channel_id: js['afk_channel_id'] == null
? null
: Snowflake.parse(js['afk_channel_id'], Snowflake.DiscordEpoch),
afkTimeout: int.parse(js['afk_timeout']),
widgetEnabled: js['widget_enabled'] == null
? null
: bool.parse(js['widget_enabled']),
verificationLevel: int.parse(js['verification_level']),
defaultMessageNotify: int.parse(js['default_message_notifications']),
explicitContentFilter: int.parse(js['explicit_content_filter']),
roles: JsRoles,
emojis: JsEmoji,
features: JsFeatures,
mfaLevel: int.parse(js['mfa_level']),
applicationId: js['application_id'] == null
? null
: Snowflake.parse(js['application_id'], Snowflake.DiscordEpoch),
systemChannelId: js['system_channel_id'] == null
? null
: Snowflake.parse(js['system_channel_id'], Snowflake.DiscordEpoch),
systemChannelFlags: int.parse(js['system_channel_flags']),
rulesChannelId: js['rules_channel_id'] == null
? null
: Snowflake.parse(js['rules_channel_id'], Snowflake.DiscordEpoch),
maxPresences: js.containsKey("max_presences")
? int.parse(js['max_presences'])
: null,
maxMembers:
js.containsKey("max_members") ? int.parse(js['max_members']) : null,
vanityUrlCode: setor(js, "vanity_url_code", null),
description: setor(js, "description", null),
banner: setor(js, "banner", null),
premiumTier: int.parse(js['premium_tier']),
premiumSubscriptionCount: js.containsKey("premium_subscription_count")
? int.parse(js['premium_subscription_count'])
: null,
preferredLocale: js['preferred_locale'],
publicUpdateChannelId: js['public_updates_channel_id'] == null
? null
: Snowflake.parse(
js['public_updates_channel_id'], Snowflake.DiscordEpoch),
maxVideoChannelUsers: js.containsKey("max_video_channel_users")
? int.parse(js['max_video_channel_users'])
: null,
maxStageVideoChannelUsers:
js.containsKey("max_stage_video_channel_users")
? int.parse(js['max_stage_video_channel_users'])
: null,
approximateMemberCount: js.containsKey("approximate_member_count")
? int.parse(js['approximate_member_count'])
: null,
approximatePresenceCount: js.containsKey("approximate_presence_count")
? int.parse(js['approximate_presence_count'])
: null,
welcomeScreen: js.containsKey("welcome_screen")
? WelcomeScreen.decode(js['welcome_screen'])
: null,
nsfwLevel: int.parse(js['nsfw_level']),
stickers: JsSStickers,
premiumProgressBarEnabled:
bool.parse(js['premium_progress_bar_enabled']),
safetyAlertsChannelId: js['safety_alerts_channel_id'] != null
? Snowflake.parse(
js['safety_alerts_channel_id'], Snowflake.DiscordEpoch)
: null);
}