diff --git a/.vscode/settings.json b/.vscode/settings.json index fe8877c72..ca292ec77 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "deno.enable": true, "editor.formatOnSave": true, + "deno.autoFmtOnSave": true, "deno.unstable": true } diff --git a/module/client.ts b/module/client.ts index 6009da90f..be1ba74ef 100644 --- a/module/client.ts +++ b/module/client.ts @@ -33,7 +33,7 @@ export const createClient = async (data: ClientOptions) => { authorization = `Bot ${data.token}`; // Initial API connection to get info about bots connection - botGatewayData = await RequestManager.get(endpoints.GATEWAY_BOT); + botGatewayData = await RequestManager.get(endpoints.GATEWAY_BOT) as DiscordBotGatewayData; identifyPayload.token = data.token; identifyPayload.intents = data.intents.reduce( diff --git a/module/requestManager.ts b/module/requestManager.ts index 12e7f1f51..bb7391d2b 100644 --- a/module/requestManager.ts +++ b/module/requestManager.ts @@ -41,12 +41,7 @@ processRateLimitedPaths(); export const RequestManager = { // Something off about using runMethod with get breaks when using fetch get: async (url: string, body?: unknown) => { - await checkRatelimits(url); - const result = await fetch(url, createRequestBody(body)); - handleStatusCode(result.status); - processHeaders(url, result.headers); - - return result.json(); + return runMethod(RequestMethod.Get, url, body) }, post: (url: string, body?: unknown) => { return runMethod(RequestMethod.Post, url, body); @@ -62,7 +57,7 @@ export const RequestManager = { }, }; -function createRequestBody(body: any, method?: RequestMethod) { +function createRequestBody(body: any, method: RequestMethod) { return { headers: { Authorization: authorization, @@ -72,7 +67,7 @@ function createRequestBody(body: any, method?: RequestMethod) { "X-Audit-Log-Reason": body ? encodeURIComponent(body.reason) : "", }, body: JSON.stringify(body), - method: method?.toUpperCase(), + method: method.toUpperCase(), }; } diff --git a/structures/channel.ts b/structures/channel.ts index 4db14c4ff..f4da7c327 100644 --- a/structures/channel.ts +++ b/structures/channel.ts @@ -59,7 +59,7 @@ export function createChannel(data: ChannelCreatePayload) { } const result = await RequestManager.get( endpoints.CHANNEL_MESSAGE(data.id, id), - ); + ) as MessageCreateOptions; return createMessage(result); }, /** Fetches between 2-100 messages. Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY */