rewrite store

this probably should have been broken up into smaller commits. oh well
This commit is contained in:
ouwou
2021-10-28 00:31:35 -04:00
parent 84b1b62e0e
commit d425997c26
12 changed files with 1990 additions and 1197 deletions

View File

@@ -191,8 +191,11 @@ std::vector<Snowflake> GuildData::GetSortedChannels(Snowflake ignore) const {
std::vector<RoleData> GuildData::FetchRoles() const {
if (!Roles.has_value()) return {};
std::vector<RoleData> ret;
for (const auto thing : *Roles)
ret.push_back(*Abaddon::Get().GetDiscordClient().GetRole(thing.ID));
for (const auto thing : *Roles) {
auto r = Abaddon::Get().GetDiscordClient().GetRole(thing.ID);
if (r.has_value())
ret.push_back(*r);
}
std::sort(ret.begin(), ret.end(), [](const RoleData &a, const RoleData &b) -> bool {
return a.Position > b.Position;
});