Files
discordeno/rest/checkRateLimits.ts
ITOH 9980856eef refactor!: fix some spelling mistakes (#2144)
* refactor!: fix some spelling mistakes
This fixes some spelling mistakes around the code base. Note not all are fixed.

* subComponent
2022-03-31 14:16:34 +02:00

18 lines
511 B
TypeScript

import { RestManager } from "../bot.ts";
/** Check the rate limits for a url or a bucket. */
export function checkRateLimits(rest: RestManager, url: string) {
const ratelimited = rest.rateLimitedPaths.get(url);
const global = rest.rateLimitedPaths.get("global");
const now = Date.now();
if (ratelimited && now < ratelimited.resetTimestamp) {
return ratelimited.resetTimestamp - now;
}
if (global && now < global.resetTimestamp) {
return global.resetTimestamp - now;
}
return false;
}