Skip to content

Commit

Permalink
put back commented out role caching
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis committed Jun 15, 2024
1 parent 9ab1b3c commit 8c27ca5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions modules/trivia/webrequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,16 +430,16 @@ void cache_user(const dpp::user *_user, const dpp::guild *_guild, const dpp::gui

std::string member_roles;
std::string comma_roles;
for (auto r = gi->get_roles().begin();r != gi->get_roles().end(); ++r) {
member_roles.append(std::to_string(*r)).append(" ");
for (auto r : gi->get_roles()) {
member_roles.append(std::to_string(r)).append(" ");
}
member_roles = trim(member_roles);
db::backgroundquery("INSERT INTO trivia_guild_membership (guild_id, user_id, roles) VALUES('?', '?', '?') ON DUPLICATE KEY UPDATE roles = '?'",
{guild_id, user_id, member_roles, member_roles});

// TODO: Gather these in the dashboard via a REST API request when the user wants them. No need to be constantly caching and writing them here, removes our need to check roles at all.
/*for (auto n = _guild->roles.begin(); n != _guild->roles.end(); ++n) {
dpp::role* r = dpp::find_role(*n);
for (auto n : _guild->roles) {
dpp::role* r = dpp::find_role(n);
if (r) {
comma_roles.append(std::to_string(r->id)).append(",");
db::backgroundquery("INSERT INTO trivia_role_cache (id, guild_id, colour, permissions, position, hoist, managed, mentionable, name) VALUES('?', '?', '?', '?', '?', '?', '?', '?', '?') ON DUPLICATE KEY UPDATE colour = '?', permissions = '?', position = '?', hoist = '?', managed = '?', mentionable = '?', name = '?'",
Expand All @@ -449,9 +449,9 @@ void cache_user(const dpp::user *_user, const dpp::guild *_guild, const dpp::gui
});
}
}
comma_roles = trim(comma_roles.substr(0, comma_roles.length() - 1));*/
comma_roles = trim(comma_roles.substr(0, comma_roles.length() - 1));
/* Delete any that have been deleted from discord */
//db::backgroundquery("DELETE FROM trivia_role_cache WHERE guild_id = ? AND id NOT IN (" + comma_roles + ")", {guild_id});
db::backgroundquery("DELETE FROM trivia_role_cache WHERE guild_id = ? AND id NOT IN (" + comma_roles + ")", {guild_id});
}

/* Fetch a question by ID from the database */
Expand Down

0 comments on commit 8c27ca5

Please sign in to comment.