Merge branch 'main' of https://github.com/discordeno/discordeno into fix-rest-issues

This commit is contained in:
Skillz4Killz
2021-04-08 14:14:49 +00:00
committed by GitHub
83 changed files with 845 additions and 394 deletions
+4 -6
View File
@@ -1,16 +1,14 @@
import { Errors } from "../types/misc/errors.ts";
import { IMAGE_BASE_URL } from "../util/constants.ts";
import { API_VERSION } from "../util/constants.ts";
import { BASE_URL } from "../util/constants.ts";
import { API_VERSION, BASE_URL, IMAGE_BASE_URL } from "../util/constants.ts";
import { rest } from "./rest.ts";
export function runMethod(
export function runMethod<T = any>(
method: "get" | "post" | "put" | "delete" | "patch",
url: string,
body?: unknown,
retryCount = 0,
bucketId?: string | null,
) {
): Promise<T | undefined> {
rest.eventHandlers.debug?.("requestCreate", {
method,
url,
@@ -37,7 +35,7 @@ export function runMethod(
.then((res) => {
if (res.status === 204) return undefined;
return res.json();
return res.json() as unknown as T;
})
.catch((error) => {
console.error(error);