mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-19 20:11:59 +03:00
cache channels
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user