mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
refactor: resolve promises (#515)
* Adding missing await and updating some deps * Adding missing await and updating some deps * Adding missing await and updating some deps * Fix close code 4009 until deno fixes the issue: https://github.com/denoland/deno/pull/8776 * Fix heartbeating * Add await for the requestGuildMembers in requestAllMembers * Change body && body.file to body?.file * Fix lint #1 * Change body && body.file to body?.file * Fix lint * Deno lint * Update request.ts * Fix deno lint error * Update src/ws/shard_manager.ts Co-authored-by: ayntee <ayyantee@gmail.com> * Fix fetchMembers * Fix getMembersByQuery * Try to fix RequestMembersQueue processing * Deno lint * Fix requestGuildMembers * Fix requestGuildMembers * Fix requestAllMembers * Undo useless changes * Fix merge conflict * Fix merge conflict * Change for loop to Promise.all * Deno fmt Co-authored-by: ayntee <ayyantee@gmail.com> Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
This commit is contained in:
@@ -121,7 +121,7 @@ async function processQueue() {
|
||||
}
|
||||
|
||||
if (Object.keys(pathQueues).length) {
|
||||
await cleanupQueues();
|
||||
cleanupQueues();
|
||||
} else queueInProcess = false;
|
||||
}
|
||||
}
|
||||
@@ -230,7 +230,8 @@ function runMethod(
|
||||
}
|
||||
|
||||
// No proxy so we need to handle all rate limiting and such
|
||||
return new Promise((resolve, reject) => {
|
||||
// deno-lint-ignore no-async-promise-executor
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const callback = async () => {
|
||||
try {
|
||||
const rateLimitResetIn = await checkRatelimits(url);
|
||||
@@ -262,7 +263,7 @@ function runMethod(
|
||||
},
|
||||
);
|
||||
const bucketIDFromHeaders = processHeaders(url, response.headers);
|
||||
handleStatusCode(response, errorStack);
|
||||
await handleStatusCode(response, errorStack);
|
||||
|
||||
// Sometimes Discord returns an empty 204 response that can't be made to JSON.
|
||||
if (response.status === 204) return resolve(undefined);
|
||||
@@ -314,7 +315,7 @@ function runMethod(
|
||||
});
|
||||
if (!queueInProcess) {
|
||||
queueInProcess = true;
|
||||
processQueue();
|
||||
await processQueue();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -336,7 +337,7 @@ async function logErrors(response: Response, errorStack?: unknown) {
|
||||
}
|
||||
}
|
||||
|
||||
function handleStatusCode(response: Response, errorStack?: unknown) {
|
||||
async function handleStatusCode(response: Response, errorStack?: unknown) {
|
||||
const status = response.status;
|
||||
|
||||
if (
|
||||
@@ -346,7 +347,7 @@ function handleStatusCode(response: Response, errorStack?: unknown) {
|
||||
return true;
|
||||
}
|
||||
|
||||
logErrors(response, errorStack);
|
||||
await logErrors(response, errorStack);
|
||||
|
||||
switch (status) {
|
||||
case HttpResponseCode.BadRequest:
|
||||
|
||||
Reference in New Issue
Block a user