Skip to content

Commit

Permalink
fix bad optional access in channel delete (fixes #187)
Browse files Browse the repository at this point in the history
  • Loading branch information
ouwou committed Jul 6, 2023
1 parent 8a5f23f commit 9a3f6b4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/discord/discord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1826,9 +1826,12 @@ void DiscordClient::HandleGatewayPresenceUpdate(const GatewayMessage &msg) {
void DiscordClient::HandleGatewayChannelDelete(const GatewayMessage &msg) {
const auto id = msg.Data.at("id").get<Snowflake>();
const auto channel = GetChannel(id);
auto it = m_guild_to_channels.find(*channel->GuildID);
if (it != m_guild_to_channels.end())
it->second.erase(id);
if (channel.has_value() && channel->GuildID.has_value()) {
auto it = m_guild_to_channels.find(*channel->GuildID);
if (it != m_guild_to_channels.end()) {
it->second.erase(id);
}
}
m_store.ClearChannel(id);
m_signal_channel_delete.emit(id);
m_signal_channel_accessibility_changed.emit(id, false);
Expand Down

0 comments on commit 9a3f6b4

Please sign in to comment.