From c001c0e08a37936408adb467e66a6ecc97b5ca9d Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 28 Aug 2020 18:21:18 -0400 Subject: dont crash on unavailable guild --- discord/discord.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'discord') diff --git a/discord/discord.cpp b/discord/discord.cpp index 7a75b95..7139f2d 100644 --- a/discord/discord.cpp +++ b/discord/discord.cpp @@ -255,7 +255,10 @@ void DiscordClient::HandleGatewayReady(const GatewayMessage &msg) { m_ready_received = true; ReadyEventData data = msg.Data; for (const auto &g : data.Guilds) { - StoreGuild(g.ID, g); + if (g.IsUnavailable) + printf("guild (%lld) unavailable\n", g.ID); + else + StoreGuild(g.ID, g); } m_abaddon->DiscordNotifyReady(); m_user_settings = data.UserSettings; @@ -368,6 +371,11 @@ void from_json(const nlohmann::json &j, UserData &m) { void from_json(const nlohmann::json &j, GuildData &m) { JS_D("id", m.ID); + if (j.contains("unavailable")) { + m.IsUnavailable = true; + return; + } + JS_D("name", m.Name); JS_N("icon", m.Icon); JS_N("splash", m.Splash); -- cgit v1.2.3