Files
discordeno/rest/processGlobalQueue.ts
Skillz4Killz 76ea7d9a67 Bucking Rest (#2588)
* Pending changes exported from your codespace

* fix: more testing needed

* fix: try fix

* fix: global shared scope erro

* fix: cleanup console logs
2022-11-14 12:17:29 -06:00

35 lines
1.1 KiB
TypeScript

import { RestRequest,RestPayload } from "./rest.ts";
import { RestManager } from "./restManager.ts";
export async function processGlobalQueue(rest: RestManager, request: {
request: RestRequest;
payload: RestPayload;
basicURL: string;
urlToUse: string;
}) {
// Check if this request is able to be made globally
await rest.invalidBucket.waitUntilRequestAvailable();
// Check if this request is able to be made for it's specific bucket
// await rest.buckets.get()
await rest.sendRequest(rest, {
url: request.urlToUse,
method: request.request.method,
bucketId: request.payload.bucketId,
reject: request.request.reject,
respond: request.request.respond,
retryRequest: function () {
rest.processGlobalQueue(rest, request);
},
retryCount: request.payload.retryCount ?? 0,
payload: rest.createRequestBody(rest, {
method: request.request.method,
body: request.payload.body,
url: request.urlToUse,
}),
})
// Should be handled in sendRequest, this catch just prevents bots from dying
.catch(() => null);
}