Skip to content

Commit

Permalink
Add rate limit tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
KwikKill committed Sep 5, 2024
1 parent 7528d17 commit 05b473d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions util/lol_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ class LolApi {
}
if (route && client.lol.services[route] !== undefined) {
client.lol.services[route].api_limit = true;
client.lol.services[route].nb_rate_limit += 1;
}
await delay(delay_time);
// Retry
Expand Down
4 changes: 3 additions & 1 deletion util/lol_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ module.exports = {
this.services[x]["queue_length"] = 0;
this.services[x]["api_limit"] = false;
this.services[x]["last"] = null;
this.services[x]["nb_rate_limit"] = 0;
}
}
},
Expand Down Expand Up @@ -1069,6 +1070,7 @@ module.exports = {
return;
}
this.services[route]["running"] = true;
this.services[route]["nb_rate_limit"] = 0;

const start = Date.now();
while (this.services[route]["queue"]["summoners"].length > 0) {
Expand Down Expand Up @@ -1403,7 +1405,7 @@ module.exports = {
if (this.services[route]["queue"]["summoners"].length > 0 || this.services[route]["queue"]["updates"].length > 0) {
return await this.main();
}
//await client.channels.cache.get("991052056657793124").send("Finished updating");
await this.client.channels.cache.get("991052056657793124").send("Finished updating " + route + " in " + (end - start) + "ms with " + this.services[route]["nb_rate_limit"] + " rate limits.");
},

/**
Expand Down

0 comments on commit 05b473d

Please sign in to comment.