/* * Vencord, a Discord client mod * Copyright (c) 2023 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ import { definePluginSettings } from "@api/Settings"; import { Link } from "@components/Link"; import { EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { User } from "discord-types/general"; 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", type: OptionType.SELECT, options: [ { label: "UserPFP", value: false }, { label: "Nitro", value: true, default: true }, ], }, databaseToUse: { type: OptionType.SELECT, description: "Which Database url to use to load avatars, KNOW WHAT YOUR DOING", options: [ { label: "UserPFP Main DB", value: "https://userpfp.github.io/UserPFP/source/data.json", default: true }, { label: "UserPFP Backup DB", value: "https://userpfp.equicord.org/data.json" } ] } }); export default definePlugin({ data, name: "UserPFP", description: "Allows you to use an animated avatar without Nitro", authors: [EquicordDevs.nexpid, EquicordDevs.thororen], settings, settingsAboutComponent: () => ( <> Submit your own PFP here!

Support UserPFP here! ), patches: [ { find: "getUserAvatarURL:", replacement: [ { match: /(getUserAvatarURL:)(\i),/, replace: "$1$self.getAvatarHook($2)," } ] } ], getAvatarHook: (original: any) => (user: User, animated: boolean, size: number) => { if (settings.store.preferNitro && user.avatar?.startsWith("a_")) return original(user, animated, size); return data.avatars[user.id] ?? original(user, animated, size); }, async start() { await fetch(settings.store.databaseToUse) .then(async res => { if (res.ok) this.data = data = await res.json(); }) .catch(() => null); } });