mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-18 02:47:03 -04:00
Donor Badges && Add donate info to settings
This commit is contained in:
parent
8b3f290e3c
commit
410613726b
5 changed files with 193 additions and 4 deletions
|
@ -17,9 +17,16 @@
|
|||
*/
|
||||
|
||||
import { BadgePosition, ProfileBadge } from "../api/Badges";
|
||||
import DonateButton from "../components/DonateButton";
|
||||
import ErrorBoundary from "../components/ErrorBoundary";
|
||||
import { Flex } from "../components/Flex";
|
||||
import { Heart } from "../components/Heart";
|
||||
import { Devs } from "../utils/constants";
|
||||
import IpcEvents from "../utils/IpcEvents";
|
||||
import Logger from "../utils/Logger";
|
||||
import { closeModal, Modals, openModal } from "../utils/modal";
|
||||
import definePlugin from "../utils/types";
|
||||
import { Forms, Margins } from "../webpack/common";
|
||||
|
||||
const CONTRIBUTOR_BADGE = "https://media.discordapp.net/stickers/1026517526106087454.webp";
|
||||
|
||||
|
@ -40,6 +47,8 @@ const ContributorBadge: ProfileBadge = {
|
|||
onClick: () => VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/Vendicated/Vencord")
|
||||
};
|
||||
|
||||
const DonorBadges = {} as Record<string, Pick<ProfileBadge, "image" | "tooltip">>;
|
||||
|
||||
export default definePlugin({
|
||||
name: "BadgeAPI",
|
||||
description: "API to add badges to users.",
|
||||
|
@ -64,7 +73,89 @@ export default definePlugin({
|
|||
}
|
||||
}
|
||||
],
|
||||
start() {
|
||||
|
||||
async start() {
|
||||
Vencord.Api.Badges.addBadge(ContributorBadge);
|
||||
const badges = await fetch("https://gist.githubusercontent.com/Vendicated/51a3dd775f6920429ec6e9b735ca7f01/raw/badges.csv").then(r => r.text());
|
||||
const lines = badges.trim().split("\n");
|
||||
if (lines.shift() !== "id,tooltip,image") {
|
||||
new Logger("BadgeAPI").error("Invalid badges.csv file!");
|
||||
return;
|
||||
}
|
||||
for (const line of lines) {
|
||||
const [id, tooltip, image] = line.split(",");
|
||||
DonorBadges[id] = { image, tooltip };
|
||||
}
|
||||
},
|
||||
|
||||
addDonorBadge(badges: ProfileBadge[], userId: string) {
|
||||
const badge = DonorBadges[userId];
|
||||
if (badge) {
|
||||
badges.unshift({
|
||||
...badge,
|
||||
position: BadgePosition.START,
|
||||
props: {
|
||||
style: {
|
||||
borderRadius: "50%",
|
||||
transform: "scale(0.9)" // The image is a bit too big compared to default badges
|
||||
}
|
||||
},
|
||||
onClick() {
|
||||
const modalKey = openModal(props => (
|
||||
<ErrorBoundary noop onError={() => {
|
||||
closeModal(modalKey);
|
||||
VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/sponsors/Vendicated");
|
||||
}}>
|
||||
<Modals.ModalRoot {...props}>
|
||||
<Modals.ModalHeader>
|
||||
<Flex style={{ width: "100%", justifyContent: "center" }}>
|
||||
<Forms.FormTitle
|
||||
tag="h2"
|
||||
style={{
|
||||
width: "100%",
|
||||
textAlign: "center",
|
||||
margin: 0
|
||||
}}
|
||||
>
|
||||
<Heart />
|
||||
Vencord Donor
|
||||
</Forms.FormTitle>
|
||||
</Flex>
|
||||
</Modals.ModalHeader>
|
||||
<Modals.ModalContent>
|
||||
<Flex>
|
||||
<img
|
||||
role="presentation"
|
||||
src="https://cdn.discordapp.com/emojis/1026533070955872337.png"
|
||||
alt=""
|
||||
style={{ margin: "auto" }}
|
||||
/>
|
||||
<img
|
||||
role="presentation"
|
||||
src="https://cdn.discordapp.com/emojis/1026533090627174460.png"
|
||||
alt=""
|
||||
style={{ margin: "auto" }}
|
||||
/>
|
||||
</Flex>
|
||||
<div style={{ padding: "1em" }}>
|
||||
<Forms.FormText>
|
||||
This Badge is a special perk for Vencord Donors
|
||||
</Forms.FormText>
|
||||
<Forms.FormText className={Margins.marginTop20}>
|
||||
Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!!
|
||||
</Forms.FormText>
|
||||
</div>
|
||||
</Modals.ModalContent>
|
||||
<Modals.ModalFooter>
|
||||
<Flex style={{ width: "100%", justifyContent: "center" }}>
|
||||
<DonateButton />
|
||||
</Flex>
|
||||
</Modals.ModalFooter>
|
||||
</Modals.ModalRoot>
|
||||
</ErrorBoundary>
|
||||
));
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue