diff --git a/modules/trivia/webrequest.cpp b/modules/trivia/webrequest.cpp index ce992c5..f94f478 100644 --- a/modules/trivia/webrequest.cpp +++ b/modules/trivia/webrequest.cpp @@ -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 = '?'", @@ -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 */