diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-12-10 03:50:40 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-12-10 03:50:40 -0500 |
commit | 850b87c1ec0ac1abfc9a3ed5c566bbe98fba9e7c (patch) | |
tree | f2e990e7a1a84ffa3f2e825ac7e1380826d7de9e /discord/guild.cpp | |
parent | e04545287519123982b7baa9c29dc175d4e35405 (diff) | |
download | abaddon-portaudio-850b87c1ec0ac1abfc9a3ed5c566bbe98fba9e7c.tar.gz abaddon-portaudio-850b87c1ec0ac1abfc9a3ed5c566bbe98fba9e7c.zip |
cache channels
Diffstat (limited to 'discord/guild.cpp')
-rw-r--r-- | discord/guild.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/discord/guild.cpp b/discord/guild.cpp index 31b4dd6..2663aac 100644 --- a/discord/guild.cpp +++ b/discord/guild.cpp @@ -136,14 +136,14 @@ std::vector<Snowflake> Guild::GetSortedChannels(Snowflake ignore) const { std::map<int, std::vector<const Channel *>> position_to_categories; std::map<int, std::vector<const Channel *>> orphan_channels; for (const auto &channel_id : channels) { - const auto *data = discord.GetChannel(channel_id); - if (data == nullptr) continue; - if (!data->ParentID.IsValid() && (data->Type == ChannelType::GUILD_TEXT || data->Type == ChannelType::GUILD_NEWS)) - orphan_channels[data->Position].push_back(data); - else if (data->ParentID.IsValid() && (data->Type == ChannelType::GUILD_TEXT || data->Type == ChannelType::GUILD_NEWS)) - category_to_channels[data->ParentID].push_back(data); + const auto data = discord.GetChannel(channel_id); + if (!data.has_value()) continue; + if (!data->ParentID->IsValid() && (data->Type == ChannelType::GUILD_TEXT || data->Type == ChannelType::GUILD_NEWS)) + orphan_channels[*data->Position].push_back(&*data); + else if (data->ParentID->IsValid() && (data->Type == ChannelType::GUILD_TEXT || data->Type == ChannelType::GUILD_NEWS)) + category_to_channels[*data->ParentID].push_back(&*data); else if (data->Type == ChannelType::GUILD_CATEGORY) - position_to_categories[data->Position].push_back(data); + position_to_categories[*data->Position].push_back(&*data); } for (auto &[pos, channels] : orphan_channels) { |