use of net.kodehawa.mantarobot.services.Carbonitex in project MantaroBot by Mantaro.
the class MantaroShard method updateServerCount.
public void updateServerCount() {
Config config = config().get();
Holder<Integer> guildCount = new Holder<>(jda.getGuilds().size());
String dbotsToken = config.dbotsToken;
String dbotsorgToken = config.dbotsorgToken;
if (dbotsToken != null || dbotsorgToken != null) {
Async.task("Botlist API update Thread", () -> {
int newC = jda.getGuilds().size();
try {
guildCount.accept(newC);
if (dbotsToken != null) {
log.debug("Successfully posted the botdata to bots.discord.pw: " + Unirest.post("https://bots.discord.pw/api/bots/" + jda.getSelfUser().getId() + "/stats").header("Authorization", dbotsToken).header("Content-Type", "application/json").body(new JSONObject().put("server_count", newC).put("shard_id", getId()).put("shard_count", totalShards).toString()).asString().getBody());
}
if (dbotsorgToken != null) {
log.debug("Successfully posted the botdata to discordbots.org: " + Unirest.post("https://discordbots.org/api/bots/" + jda.getSelfUser().getId() + "/stats").header("Authorization", dbotsorgToken).header("Content-Type", "application/json").body(new JSONObject().put("server_count", newC).put("shard_id", getId()).put("shard_count", totalShards).toString()).asString().getBody());
}
} catch (Exception e) {
log.warn("An error occurred while posting the botdata to discord lists (DBots/Carbonitex/DBots.org)", e);
}
}, 1, TimeUnit.HOURS);
}
//Carbon is special now.
Async.task(new Carbonitex(jda, getId(), getTotalShards()), 30, TimeUnit.MINUTES);
}
Aggregations