diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-10-08 17:52:38 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-10-08 17:52:38 -0400 |
commit | fa1a007dc12208a90c278cb426c37c9a24079636 (patch) | |
tree | 94ce7cb7a88f6e5c3144ae5e46a5cdb776237970 /discord | |
parent | abc0a7931e64cfe3db65dd85c26d0de1be1817a0 (diff) | |
download | abaddon-portaudio-fa1a007dc12208a90c278cb426c37c9a24079636.tar.gz abaddon-portaudio-fa1a007dc12208a90c278cb426c37c9a24079636.zip |
fix unchecked optionals
also discard exceptions in file cache futures
Diffstat (limited to 'discord')
-rw-r--r-- | discord/discord.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/discord/discord.cpp b/discord/discord.cpp index 10bd322..257df5c 100644 --- a/discord/discord.cpp +++ b/discord/discord.cpp @@ -152,7 +152,8 @@ void DiscordClient::FetchMessagesInChannel(Snowflake id, sigc::slot<void(const s m_store.BeginTransaction(); for (auto &msg : msgs) { StoreMessageData(msg); - AddUserToGuild(msg.Author.ID, *msg.GuildID); + if (msg.GuildID.has_value()) + AddUserToGuild(msg.Author.ID, *msg.GuildID); } m_store.EndTransaction(); @@ -300,7 +301,7 @@ bool DiscordClient::HasGuildPermission(Snowflake user_id, Snowflake guild_id, Pe bool DiscordClient::HasAnyChannelPermission(Snowflake user_id, Snowflake channel_id, Permission perm) const { const auto channel = m_store.GetChannel(channel_id); - if (!channel.has_value()) return false; + if (!channel.has_value() || !channel->GuildID.has_value()) return false; const auto base = ComputePermissions(user_id, *channel->GuildID); const auto overwrites = ComputeOverwrites(base, user_id, channel_id); return (overwrites & perm) != Permission::NONE; @@ -1400,7 +1401,8 @@ void DiscordClient::HandleGatewayReady(const GatewayMessage &msg) { void DiscordClient::HandleGatewayMessageCreate(const GatewayMessage &msg) { Message data = msg.Data; StoreMessageData(data); - AddUserToGuild(data.Author.ID, *data.GuildID); + if (data.GuildID.has_value()) + AddUserToGuild(data.Author.ID, *data.GuildID); m_signal_message_create.emit(data); } |