From 3e332a60622ef1ca525404374588e4041551aa5e Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 21 Mar 2024 23:27:08 +0100 Subject: [PATCH] fix RestAPI find --- src/webpack/common/types/utils.d.ts | 6 +----- src/webpack/common/utils.ts | 7 +++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/webpack/common/types/utils.d.ts b/src/webpack/common/types/utils.d.ts index 3d1c0eea6..39af843c5 100644 --- a/src/webpack/common/types/utils.d.ts +++ b/src/webpack/common/types/utils.d.ts @@ -81,11 +81,7 @@ interface RestRequestData { retries?: number; } -export type RestAPI = Record<"delete" | "get" | "patch" | "post" | "put", (data: RestRequestData) => Promise> & { - V6OrEarlierAPIError: Error; - V8APIError: Error; - getAPIBaseURL(withVersion?: boolean): string; -}; +export type RestAPI = Record<"delete" | "get" | "patch" | "post" | "put", (data: RestRequestData) => Promise>; export type Permissions = "CREATE_INSTANT_INVITE" | "KICK_MEMBERS" diff --git a/src/webpack/common/utils.ts b/src/webpack/common/utils.ts index 7060573d5..ec6c0e1ed 100644 --- a/src/webpack/common/utils.ts +++ b/src/webpack/common/utils.ts @@ -19,7 +19,7 @@ import type { Channel, User } from "discord-types/general"; // eslint-disable-next-line path-alias/no-relative -import { _resolveReady, filters, findByCodeLazy, findByPropsLazy, findLazy, waitFor } from "../webpack"; +import { _resolveReady, filters, findByCodeLazy, findByProps, findByPropsLazy, findLazy, proxyLazyWebpack, waitFor } from "../webpack"; import type * as t from "./types/utils"; export let FluxDispatcher: t.FluxDispatcher; @@ -37,7 +37,10 @@ export let ComponentDispatch; waitFor(["ComponentDispatch", "ComponentDispatcher"], m => ComponentDispatch = m.ComponentDispatch); -export const RestAPI: t.RestAPI = findByPropsLazy("getAPIBaseURL", "get"); +export const RestAPI: t.RestAPI = proxyLazyWebpack(() => { + const mod = findByProps("getAPIBaseURL"); + return mod.HTTP ?? mod; +}); export const moment: typeof import("moment") = findByPropsLazy("parseTwoDigitYear"); export const hljs: typeof import("highlight.js") = findByPropsLazy("highlight", "registerLanguage");