mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
ebb15afa0e
* shtufffff * fixe rate limit path infinite loop * refactor * ID > id * Update process_request_headers.ts * file names Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> Co-authored-by: ayntee <ayyantee@gmail.com>
18 lines
485 B
TypeScript
18 lines
485 B
TypeScript
import { rest } from "./rest.ts";
|
|
|
|
/** Check the rate limits for a url or a bucket. */
|
|
export function checkRateLimits(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;
|
|
}
|