summaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
Diffstat (limited to 'discord')
-rw-r--r--discord/guild.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/discord/guild.cpp b/discord/guild.cpp
index 94268d8..054a2c3 100644
--- a/discord/guild.cpp
+++ b/discord/guild.cpp
@@ -14,10 +14,10 @@ void from_json(const nlohmann::json &j, Guild &m) {
JS_ON("discovery_splash", m.DiscoverySplash);
JS_O("owner", m.IsOwner);
JS_D("owner_id", m.OwnerID);
- std::string tmp;
+ std::optional<std::string> tmp;
JS_O("permissions", tmp);
- if (tmp != "")
- m.Permissions = std::stoull(tmp);
+ if (tmp.has_value())
+ m.Permissions = std::stoull(*tmp);
JS_D("region", m.VoiceRegion);
JS_N("afk_channel_id", m.AFKChannelID);
JS_D("afk_timeout", m.AFKTimeout);
@@ -54,8 +54,12 @@ void from_json(const nlohmann::json &j, Guild &m) {
JS_D("preferred_locale", m.PreferredLocale);
JS_N("public_updates_channel_id", m.PublicUpdatesChannelID);
JS_O("max_video_channel_users", m.MaxVideoChannelUsers);
- JS_O("approximate_member_count", m.ApproximateMemberCount);
- JS_O("approximate_presence_count", m.ApproximatePresenceCount);
+ JS_O("approximate_member_count", tmp);
+ if (tmp.has_value())
+ m.ApproximateMemberCount = std::stoull(*tmp);
+ JS_O("approximate_presence_count", tmp);
+ if (tmp.has_value())
+ m.ApproximatePresenceCount = std::stoull(*tmp);
}
void Guild::update_from_json(const nlohmann::json &j) {