aboutsummaryrefslogtreecommitdiff
path: root/src/hypixelApi.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/hypixelApi.ts')
-rw-r--r--src/hypixelApi.ts15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/hypixelApi.ts b/src/hypixelApi.ts
index 72af1af..a212f34 100644
--- a/src/hypixelApi.ts
+++ b/src/hypixelApi.ts
@@ -36,7 +36,7 @@ export function chooseApiKey(): string {
// find the api key with the lowest amount of uses
let bestKeyUsage: KeyUsage = null
let bestKey: string = null
- for (var key of shuffle(apiKeys)) {
+ for (let key of shuffle(apiKeys)) {
const keyUsage = apiKeyUsage[key]
// if the key has never been used before, use it
@@ -55,6 +55,19 @@ export function chooseApiKey(): string {
return bestKey
}
+export function getKeyUsage() {
+ let keyLimit = 0
+ let keyUsage = 0
+ for (let key of Object.values(apiKeyUsage)) {
+ keyLimit += key.limit
+ keyUsage += key.limit - key.remaining
+ }
+ return {
+ limit: keyLimit,
+ usage: keyUsage
+ }
+}
+
export interface HypixelResponse {
[key: string]: any | {
success: boolean