From 854769cd22656d571026a9ea9ea212371cf7e239 Mon Sep 17 00:00:00 2001 From: thororen <78185467+thororen1234@users.noreply.github.com> Date: Sat, 20 Apr 2024 13:54:06 -0400 Subject: [PATCH] feat(UsrBG & UserPFP): UrlForDB Setting --- src/equicordplugins/userpfp/index.tsx | 13 ++++++++----- src/plugins/usrbg/index.tsx | 10 +++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/equicordplugins/userpfp/index.tsx b/src/equicordplugins/userpfp/index.tsx index 46c98b4d..f741db99 100644 --- a/src/equicordplugins/userpfp/index.tsx +++ b/src/equicordplugins/userpfp/index.tsx @@ -10,22 +10,25 @@ import { EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { User } from "discord-types/general"; -const BASE_URL = "https://userpfp.github.io/UserPFP/source/data.json"; - let data = { avatars: {} as Record, }; const settings = definePluginSettings({ preferNitro: { - description: - "Which avatar to use if both default animated (Nitro) pfp and UserPFP avatars are present", + description: "Which avatar to use if both default animated (Nitro) pfp and UserPFP avatars are present", type: OptionType.SELECT, options: [ { label: "UserPFP", value: false }, { label: "Nitro", value: true, default: true }, ], }, + urlForDB: { + type: OptionType.STRING, + description: "Which Database url to use to load avatars, KNOW WHAT YOUR DOING", + default: "https://userpfp.github.io/UserPFP/source/data.json", + placeholder: "Default value: https://userpfp.github.io/UserPFP/source/data.json" + } }); export default definePlugin({ @@ -67,7 +70,7 @@ export default definePlugin({ return data.avatars[user.id] ?? original(user, animated, size); }, async start() { - const res = await fetch(BASE_URL); + const res = await fetch(settings.store.urlForDB); if (res.ok) this.data = data = await res.json(); } }); diff --git a/src/plugins/usrbg/index.tsx b/src/plugins/usrbg/index.tsx index ce6bd709..146a199c 100644 --- a/src/plugins/usrbg/index.tsx +++ b/src/plugins/usrbg/index.tsx @@ -24,8 +24,6 @@ import definePlugin, { OptionType } from "@utils/types"; import style from "./index.css?managed"; -const BASE_URL = "https://raw.githubusercontent.com/AutumnVN/usrbg/main/usrbg.json"; - let data = {} as Record; const settings = definePluginSettings({ @@ -42,6 +40,12 @@ const settings = definePluginSettings({ type: OptionType.BOOLEAN, default: true, restartNeeded: true + }, + urlForDB: { + type: OptionType.STRING, + description: "Which Database url to use to load banners, KNOW WHAT YOUR DOING", + default: "https://raw.githubusercontent.com/AutumnVN/usrbg/main/usrbg.json", + placeholder: "Default value: https://raw.githubusercontent.com/AutumnVN/usrbg/main/usrbg.json" } }); @@ -118,7 +122,7 @@ export default definePlugin({ async start() { enableStyle(style); - const res = await fetch(BASE_URL); + const res = await fetch(settings.store.urlForDB); if (res.ok) { data = await res.json(); this.data = data;