From 8cfe2ab7f69e2aa656febad8e80b49676d07ea0e Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Mon, 17 Nov 2025 12:26:19 -0500 Subject: [PATCH] GlobalBadges: Allow Different API URLs --- src/equicordplugins/globalBadges/settings.ts | 10 ++++++++++ src/equicordplugins/globalBadges/utils.ts | 3 +-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/equicordplugins/globalBadges/settings.ts b/src/equicordplugins/globalBadges/settings.ts index a8c37f5e3..669aa23e7 100644 --- a/src/equicordplugins/globalBadges/settings.ts +++ b/src/equicordplugins/globalBadges/settings.ts @@ -73,5 +73,15 @@ export const settings = definePluginSettings({ description: "Show Replugged Badges", default: true, restartNeeded: false + }, + apiUrl: { + type: OptionType.STRING, + description: "API to use", + default: "https://badges.equicord.org/", + restartNeeded: false, + onChange: (e => { + if (!e || !e.startsWith("https://")) return settings.store.apiUrl = "https://badges.equicord.org/"; + return e; + }) } }); diff --git a/src/equicordplugins/globalBadges/utils.ts b/src/equicordplugins/globalBadges/utils.ts index 6c715b5d9..d63932d37 100644 --- a/src/equicordplugins/globalBadges/utils.ts +++ b/src/equicordplugins/globalBadges/utils.ts @@ -9,7 +9,6 @@ import { classNameFactory } from "@api/Styles"; import { settings } from "./settings"; import { BadgeCache } from "./types"; -const API_URL = "https://badges.equicord.org/"; const cache = new Map(); const EXPIRES = 1000 * 60 * 15; @@ -45,7 +44,7 @@ export const fetchBadges = (id: string): BadgeCache["badges"] | undefined => { return {}; } - fetch(`${API_URL}${id}?seperated=true&services=${services.join(",")}`) + fetch(`${settings.store.apiUrl}${id}?seperated=true&services=${services.join(",")}`) .then(res => res.json() as Promise<{ status: number; badges: BadgeCache["badges"]; }>) .then(body => { cache.set(id, { badges: body.badges, expires: Date.now() + EXPIRES });