Merge Dev & Optimize Some Stuff

This commit is contained in:
thororen1234 2025-05-14 14:46:57 -04:00
commit 0fae2ee510
No known key found for this signature in database
16 changed files with 233 additions and 200 deletions

View file

@ -19,21 +19,18 @@
import "./fixDiscordBadgePadding.css";
import { _getBadges, BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges";
import DonateButton, { VCDonateButton } from "@components/DonateButton";
import ErrorBoundary from "@components/ErrorBoundary";
import { Flex } from "@components/Flex";
import { Heart } from "@components/Heart";
import { openContributorModal } from "@components/PluginSettings/ContributorModal";
import { isEquicordDonor } from "@components/VencordSettings/VencordTab";
import { Devs } from "@utils/constants";
import { Logger } from "@utils/Logger";
import { Margins } from "@utils/margins";
import { isEquicordPluginDev, isPluginDev } from "@utils/misc";
import { closeModal, ModalContent, ModalFooter, ModalHeader, ModalRoot, openModal } from "@utils/modal";
import definePlugin from "@utils/types";
import { Forms, Toasts, UserStore } from "@webpack/common";
import { Toasts, UserStore } from "@webpack/common";
import { User } from "discord-types/general";
import { EquicordDonorModal, VencordDonorModal } from "./modals";
const CONTRIBUTOR_BADGE = "https://vencord.dev/assets/favicon.png";
const EQUICORD_CONTRIBUTOR_BADGE = "https://i.imgur.com/57ATLZu.png";
const EQUICORD_DONOR_BADGE = "https://cdn.nest.rip/uploads/78cb1e77-b7a6-4242-9089-e91f866159bf.png";
@ -62,6 +59,9 @@ const EquicordDonorBadge: ProfileBadge = {
const donorBadges = EquicordDonorBadges[userId]?.map(badge => badge.badge);
const hasDonorBadge = donorBadges?.includes("https://cdn.nest.rip/uploads/78cb1e77-b7a6-4242-9089-e91f866159bf.png");
return isEquicordDonor(userId) && !hasDonorBadge;
},
onClick: () => {
return EquicordDonorModal();
}
};
@ -83,6 +83,7 @@ async function loadAllBadges(noCache = false) {
EquicordDonorBadges = equicordBadges;
}
let intervalId: any;
export default definePlugin({
name: "BadgeAPI",
@ -117,6 +118,15 @@ export default definePlugin({
}
],
// for access from the console or other plugins
get DonorBadges() {
return DonorBadges;
},
get EquicordDonorBadges() {
return EquicordDonorBadges;
},
toolboxActions: {
async "Refetch Badges"() {
await loadAllBadges(true);
@ -128,11 +138,16 @@ export default definePlugin({
}
},
userProfileBadges: [ContributorBadge, EquicordContributorBadge, EquicordDonorBadge],
async start() {
Vencord.Api.Badges.addProfileBadge(ContributorBadge);
Vencord.Api.Badges.addProfileBadge(EquicordContributorBadge);
Vencord.Api.Badges.addProfileBadge(EquicordDonorBadge);
await loadAllBadges();
clearInterval(intervalId);
intervalId = setInterval(loadAllBadges, 1000 * 60 * 30); // 30 minutes
},
async stop() {
clearInterval(intervalId);
},
getBadges(props: { userId: string; user?: User; guildId: string; }) {
@ -166,59 +181,7 @@ export default definePlugin({
}
},
onClick() {
const modalKey = openModal(props => (
<ErrorBoundary noop onError={() => {
closeModal(modalKey);
VencordNative.native.openExternal("https://github.com/sponsors/Vendicated");
}}>
<ModalRoot {...props}>
<ModalHeader>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<Forms.FormTitle
tag="h2"
style={{
width: "100%",
textAlign: "center",
margin: 0
}}
>
<Heart />
Vencord Donor
</Forms.FormTitle>
</Flex>
</ModalHeader>
<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.top20}>
Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!
</Forms.FormText>
</div>
</ModalContent>
<ModalFooter>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<VCDonateButton />
</Flex>
</ModalFooter>
</ModalRoot>
</ErrorBoundary>
));
return VencordDonorModal();
},
}));
},
@ -235,60 +198,7 @@ export default definePlugin({
}
},
onClick() {
const modalKey = openModal(props => (
<ErrorBoundary noop onError={() => {
closeModal(modalKey);
// Will get my own in the future
VencordNative.native.openExternal("https://github.com/sponsors/Vendicated");
}}>
<ModalRoot {...props}>
<ModalHeader>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<Forms.FormTitle
tag="h2"
style={{
width: "100%",
textAlign: "center",
margin: 0
}}
>
<Heart />
Equicord Donor
</Forms.FormTitle>
</Flex>
</ModalHeader>
<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 Equicord (Not Vencord) Donors
</Forms.FormText>
<Forms.FormText className={Margins.top20}>
Please consider supporting the development of Equicord by becoming a donor. It would mean a lot! :3
</Forms.FormText>
</div>
</ModalContent>
<ModalFooter>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<DonateButton />
</Flex>
</ModalFooter>
</ModalRoot>
</ErrorBoundary>
));
return EquicordDonorModal();
},
}));
}

View file

@ -0,0 +1,126 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { DonateButton, VCDonateButton } from "@components/DonateButton";
import { Flex } from "@components/Flex";
import { Heart } from "@components/Heart";
import { ErrorBoundary } from "@components/index";
import { Margins } from "@utils/margins";
import { closeModal, ModalContent, ModalFooter, ModalHeader, ModalRoot, openModal } from "@utils/modal";
import { Forms } from "@webpack/common";
export function VencordDonorModal() {
const modalKey = openModal(props => (
<ErrorBoundary noop onError={() => {
closeModal(modalKey);
VencordNative.native.openExternal("https://github.com/sponsors/Vendicated");
}}>
<ModalRoot {...props}>
<ModalHeader>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<Forms.FormTitle
tag="h2"
style={{
width: "100%",
textAlign: "center",
margin: 0
}}
>
<Heart />
Vencord Donor
</Forms.FormTitle>
</Flex>
</ModalHeader>
<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.top20}>
Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!
</Forms.FormText>
</div>
</ModalContent>
<ModalFooter>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<VCDonateButton />
</Flex>
</ModalFooter>
</ModalRoot>
</ErrorBoundary>
));
}
export function EquicordDonorModal() {
const modalKey = openModal(props => (
<ErrorBoundary noop onError={() => {
closeModal(modalKey);
// Will get my own in the future
VencordNative.native.openExternal("https://github.com/sponsors/thororen1234");
}}>
<ModalRoot {...props}>
<ModalHeader>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<Forms.FormTitle
tag="h2"
style={{
width: "100%",
textAlign: "center",
margin: 0
}}
>
<Heart />
Equicord Donor
</Forms.FormTitle>
</Flex>
</ModalHeader>
<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 Equicord (Not Vencord) Donors
</Forms.FormText>
<Forms.FormText className={Margins.top20}>
Please consider supporting the development of Equicord by becoming a donor. It would mean a lot! :3
</Forms.FormText>
</div>
</ModalContent>
<ModalFooter>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<DonateButton />
</Flex>
</ModalFooter>
</ModalRoot>
</ErrorBoundary>
));
}

View file

@ -133,7 +133,7 @@ for (const p of pluginsValues) if (isPluginEnabled(p.name)) {
if (p.renderMessageAccessory) neededApiPlugins.add("MessageAccessoriesAPI");
if (p.renderMessageDecoration) neededApiPlugins.add("MessageDecorationsAPI");
if (p.renderMessagePopoverButton) neededApiPlugins.add("MessagePopoverAPI");
if (p.userProfileBadge) neededApiPlugins.add("BadgeAPI");
if (p.userProfileBadges) neededApiPlugins.add("BadgeAPI");
for (const key of pluginKeysToBind) {
p[key] &&= p[key].bind(p) as any;
@ -261,7 +261,7 @@ export function subscribeAllPluginsFluxEvents(fluxDispatcher: typeof FluxDispatc
export const startPlugin = traceFunction("startPlugin", function startPlugin(p: Plugin) {
const {
name, commands, contextMenus, managedStyle, userProfileBadge,
name, commands, contextMenus, managedStyle, userProfileBadges,
onBeforeMessageEdit, onBeforeMessageSend, onMessageClick,
renderChatBarButton, renderMemberListDecorator, renderNicknameIcon, renderMessageAccessory, renderMessageDecoration, renderMessagePopoverButton
} = p;
@ -307,7 +307,7 @@ export const startPlugin = traceFunction("startPlugin", function startPlugin(p:
if (managedStyle) enableStyle(managedStyle);
if (userProfileBadge) addProfileBadge(userProfileBadge);
if (userProfileBadges) userProfileBadges.forEach(e => addProfileBadge(e));
if (onBeforeMessageEdit) addMessagePreEditListener(onBeforeMessageEdit);
if (onBeforeMessageSend) addMessagePreSendListener(onBeforeMessageSend);
@ -325,7 +325,7 @@ export const startPlugin = traceFunction("startPlugin", function startPlugin(p:
export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plugin) {
const {
name, commands, contextMenus, managedStyle, userProfileBadge,
name, commands, contextMenus, managedStyle, userProfileBadges,
onBeforeMessageEdit, onBeforeMessageSend, onMessageClick,
renderChatBarButton, renderMemberListDecorator, renderNicknameIcon, renderMessageAccessory, renderMessageDecoration, renderMessagePopoverButton
} = p;
@ -369,7 +369,7 @@ export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plu
if (managedStyle) disableStyle(managedStyle);
if (userProfileBadge) removeProfileBadge(userProfileBadge);
if (userProfileBadges) userProfileBadges.forEach(e => removeProfileBadge(e));
if (onBeforeMessageEdit) removeMessagePreEditListener(onBeforeMessageEdit);
if (onBeforeMessageSend) removeMessagePreSendListener(onBeforeMessageSend);

View file

@ -110,7 +110,7 @@ export default definePlugin({
patches: [
{
// Indicator
find: "#{intl::MESSAGE_EDITED}",
find: ".SEND_FAILED,",
replacement: {
match: /let\{className:\i,message:\i[^}]*\}=(\i)/,
replace: "try {$1 && $self.INV_REGEX.test($1.message.content) ? $1.content.push($self.indicator()) : null } catch {};$&"

View file

@ -487,22 +487,23 @@ export default definePlugin({
],
},
// Message content renderer
{
find: ".SEND_FAILED,",
replacement: {
// Render editHistory in the deepest div for message content
match: /(\)\("div",\{id:.+?children:\[)/,
replace: "$1 (!!arguments[0].message.editHistory?.length && $self.renderEdits(arguments[0])),"
}
},
{
// Message content renderer
find: "#{intl::MESSAGE_EDITED}",
replacement: [
{
// Render editHistory in the deepest div for message content
match: /(\)\("div",\{id:.+?children:\[)/,
replace:
"$1 (!!arguments[0].message.editHistory?.length && $self.renderEdits(arguments[0])),",
},
{
// Make edit marker clickable
match: /"span",\{(?=className:\i\.edited,)/,
replace: "$self.EditMarker,{message:arguments[0].message,",
},
],
replacement: {
// Make edit marker clickable
match: /"span",\{(?=className:\i\.edited,)/,
replace: "$self.EditMarker,{message:arguments[0].message,"
}
},
{

View file

@ -30,7 +30,7 @@ export default definePlugin({
{
find: "}searchWithoutFetchingLatest(",
replacement: {
match: /searchWithoutFetchingLatest.{20,300}get\((\i).{10,40}?reduce\(\((\i),(\i)\)=>\{/,
match: /\.get\((\i)\)\.nameMatchesChain\(\i\)\.reduce\(\((\i),(\i)\)=>\{/,
replace: "$& if ($self.shouldSkip($1, $3)) return $2;"
}
}

View file

@ -154,7 +154,7 @@ export default definePlugin({
},
// Messages
{
find: "#{intl::MESSAGE_EDITED}",
find: ".SEND_FAILED,",
replacement: {
match: /(?<=isUnsupported\]:(\i)\.isUnsupported\}\),)(?=children:\[)/,
replace: "style:$self.useMessageColorsStyle($1),"