feat(UsrBG & UserPFP): UrlForDB Setting

This commit is contained in:
thororen 2024-04-20 13:54:06 -04:00
parent b955a1c2ba
commit 854769cd22
2 changed files with 15 additions and 8 deletions

View file

@ -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<string, string>,
};
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();
}
});

View file

@ -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<string, string>;
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;