mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
chore: setup "deno lint" (#331)
* chore: setup "deno lint" * ci(lint): add --unstable flat to lint script * lint * lint * refactor: destructure assignment for Message#guildID * chore: remove TODO comment * refactor: remove redundant async * chore: switch to Deno stable vscode ext * chore: remove ignore comments * chore: remove ignore comments * chore: remove @ts-ignore comment * fixes * fixes * chore: remove deno-lint-ignore comment * chore: add index signature
This commit is contained in:
@@ -17,6 +17,7 @@ let queueInProcess = false;
|
||||
export interface QueuedRequest {
|
||||
callback: () => Promise<
|
||||
void | {
|
||||
// deno-lint-ignore no-explicit-any
|
||||
rateLimited: any;
|
||||
beforeFetch: boolean;
|
||||
bucketID?: string | null;
|
||||
@@ -58,7 +59,7 @@ function addToQueue(request: QueuedRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
async function cleanupQueues() {
|
||||
function cleanupQueues() {
|
||||
Object.entries(pathQueues).forEach(([key, value]) => {
|
||||
if (!value.length) {
|
||||
// Remove it entirely
|
||||
@@ -123,7 +124,7 @@ async function processQueue() {
|
||||
processRateLimitedPaths();
|
||||
|
||||
export const RequestManager = {
|
||||
get: async (url: string, body?: unknown) => {
|
||||
get: (url: string, body?: unknown) => {
|
||||
return runMethod("get", url, body);
|
||||
},
|
||||
post: (url: string, body?: unknown) => {
|
||||
@@ -140,6 +141,7 @@ export const RequestManager = {
|
||||
},
|
||||
};
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
function createRequestBody(body: any, method: RequestMethods) {
|
||||
const headers: { [key: string]: string } = {
|
||||
Authorization: authorization,
|
||||
@@ -170,7 +172,7 @@ function createRequestBody(body: any, method: RequestMethods) {
|
||||
};
|
||||
}
|
||||
|
||||
async function checkRatelimits(url: string) {
|
||||
function checkRatelimits(url: string) {
|
||||
const ratelimited = ratelimitedPaths.get(url);
|
||||
const global = ratelimitedPaths.get("global");
|
||||
const now = Date.now();
|
||||
@@ -185,7 +187,7 @@ async function checkRatelimits(url: string) {
|
||||
return false;
|
||||
}
|
||||
|
||||
async function runMethod(
|
||||
function runMethod(
|
||||
method: RequestMethods,
|
||||
url: string,
|
||||
body?: unknown,
|
||||
@@ -225,10 +227,12 @@ async function runMethod(
|
||||
}
|
||||
|
||||
const query = method === "get" && body
|
||||
? Object.entries(body as any).map(([key, value]) =>
|
||||
`${encodeURIComponent(key)}=${encodeURIComponent(value as any)}`
|
||||
)
|
||||
.join("&")
|
||||
? // deno-lint-ignore no-explicit-any
|
||||
Object.entries(body as any).map(([key, value]) =>
|
||||
// deno-lint-ignore no-explicit-any
|
||||
`${encodeURIComponent(key)}=${encodeURIComponent(value as any)}`
|
||||
)
|
||||
.join("&")
|
||||
: "";
|
||||
const urlToUse = method === "get" && query ? `${url}?${query}` : url;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user