Skip to content

Commit

Permalink
tidyups
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis committed Jul 8, 2024
1 parent 7869932 commit a3ae886
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions include/ssod/botlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ struct botlist {
*
* @param bot cluster reference
* @param key configuration key name
* @param url bot list url formatter
* @param api_url bot list api_url formatter
* @param count_field count field in postdata
* @param shards_field shards field in postdata
*/
static dpp::task<void> run(dpp::cluster& bot, const std::string_view key, const std::string_view url, const std::string_view count_field, const std::string_view shards_field);
static dpp::task<void> run(dpp::cluster& bot, const std::string_view key, const std::string_view api_url, const std::string_view count_field, const std::string_view shards_field);
};

/**
Expand Down
10 changes: 5 additions & 5 deletions src/botlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ dpp::task<void> post_botlists(dpp::cluster &bot) {
}
}

dpp::task<void> botlist::run(dpp::cluster& bot, const std::string_view key, const std::string_view url, const std::string_view count_field, const std::string_view shards_field) {
const json& list_config = config::get("botlists");
dpp::task<void> botlist::run(dpp::cluster& bot, const std::string_view key, const std::string_view api_url, const std::string_view count_field, const std::string_view shards_field) {
const json list_config = config::get("botlists");
auto rs = co_await db::co_query("SELECT COUNT(id) AS count FROM guild_cache");
if (list_config.contains(key.data())) {
const json& topgg_config = list_config.at(key.data());
std::string token = topgg_config.at("token");
const json this_bot_list_config = list_config.at(key.data());
std::string token = this_bot_list_config.at("token");
json j;
if (!shards_field.empty()) {
j[shards_field.data()] = bot.numshards;
}
if (!count_field.empty() && !rs.empty()) {
j[count_field.data()] = atoi(rs[0].at("count").c_str());
}
std::string post_url = replace_string(url.data(), "{}", bot.me.id.str());
std::string post_url = replace_string(api_url.data(), "{}", bot.me.id.str());
auto cc = co_await bot.co_request(post_url, dpp::m_post, j.dump(), "application/json", {{"Authorization", token}});
if (cc.status >= 400) {
bot.log(dpp::ll_warning, std::string(key) + " returned: " + cc.body);
Expand Down

0 comments on commit a3ae886

Please sign in to comment.