From 4d10691ac1b3792cceb43a9aeaa1fe9470e2b286 Mon Sep 17 00:00:00 2001 From: Beef Date: Mon, 20 Mar 2023 21:30:13 +0000 Subject: [PATCH] [TS] Various cleanups --- src/def.d.ts | 14 +++++++++----- src/lib/utils/safeFetch.ts | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/def.d.ts b/src/def.d.ts index d8b22b3..43af7de 100644 --- a/src/def.d.ts +++ b/src/def.d.ts @@ -371,7 +371,7 @@ interface VendettaObject { utils: { findInReactTree: (tree: SearchTree, filter: SearchFilter) => any; findInTree: (tree: SearchTree, filter: SearchFilter, options: FindInTreeOptions) => any; - safeFetch: (input: RequestInfo, options: RequestInit) => Promise; + safeFetch: (input: RequestInfo | URL, options?: RequestInit) => Promise; unfreeze: (obj: object) => object; }; debug: { @@ -411,17 +411,21 @@ interface VendettaObject { }; plugins: { plugins: Indexable; - fetchPlugin: (id: string, enabled: boolean) => void; - installPlugin: (id: string, enabled: boolean) => void; + fetchPlugin: (id: string) => void; + installPlugin: (id: string, enabled?: boolean) => void; evalPlugin: (plugin: Plugin) => void; - stopPlugin: (id: string, disable: boolean) => void; + stopPlugin: (id: string, disable?: boolean) => void; removePlugin: (id: string) => void; getSettings: (id: string) => JSX.Element; }; themes: { themes: Indexable; - fetchTheme: (id: string) => void; + fetchTheme: (id: string, selected?: boolean) => void; + installTheme: (id: string) => void; selectTheme: (id: string) => void; + removeTheme: (id: string) => Promise; + getCurrentTheme: () => Theme | null; + updateThemes: () => void; }; commands: { registerCommand: (command: ApplicationCommand) => () => void; diff --git a/src/lib/utils/safeFetch.ts b/src/lib/utils/safeFetch.ts index 652e517..1c743de 100644 --- a/src/lib/utils/safeFetch.ts +++ b/src/lib/utils/safeFetch.ts @@ -1,6 +1,6 @@ // A really basic fetch wrapper which throws on non-ok response codes -export default async function safeFetch(input: RequestInfo, options?: RequestInit) { +export default async function safeFetch(input: RequestInfo | URL, options?: RequestInit) { const req = await fetch(input, options); if (!req.ok) throw new Error("Request returned non-ok"); return req;