diff --git a/managers/RequestManager.ts b/managers/RequestManager.ts index 6cf220df5..8785a60b2 100644 --- a/managers/RequestManager.ts +++ b/managers/RequestManager.ts @@ -1,24 +1,38 @@ import Client from "../module/Client.ts"; +import { RequestMethod } from "../types/fetch"; + +type RequestBody = string | Blob | ArrayBufferView | ArrayBuffer | FormData | URLSearchParams | null | undefined; class RequestManager { client: Client; token: string; - currentRatelimit constructor(client: Client, token: string) { this.client = client this.token = token } - async get(url: string, payload?: unknown, shouldRatelimit = true) { - if (shouldRatelimit) { - - } + async get(url: string) { const headers = this.getDiscordHeaders(); - console.log('payload', payload) - - const data = await fetch(url, { headers }).then(res => res.json()) - return data + return fetch(url, { headers }).then(res => res.json()) + } + + async post (url: string, body: RequestBody) { + const headers = this.getDiscordHeaders(); + return fetch(url, { + method: RequestMethod.Post, + headers, + body + }); + } + + async delete (url: string, body: RequestBody) { + const headers = this.getDiscordHeaders(); + return fetch(url, { + method: RequestMethod.Delete, + headers, + body + }); } // The Record type here plays nice with Deno's `fetch.headers` expected type.