From 850b87c1ec0ac1abfc9a3ed5c566bbe98fba9e7c Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 10 Dec 2020 03:50:40 -0500 Subject: cache channels --- discord/guild.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'discord/guild.cpp') 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 Guild::GetSortedChannels(Snowflake ignore) const { std::map> position_to_categories; std::map> 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) { -- cgit v1.2.3