diff --git a/src/plugins/friendsSince/README.md b/src/plugins/friendsSince/README.md new file mode 100644 index 000000000..ccbb09b67 --- /dev/null +++ b/src/plugins/friendsSince/README.md @@ -0,0 +1,5 @@ +# FriendsSince + +Shows when you became friends with someone in the user popout + +![](https://github.com/Vendicated/Vencord/assets/45497981/bb258188-ab48-4c4d-9858-1e90ba41e926) diff --git a/src/plugins/friendsSince/index.tsx b/src/plugins/friendsSince/index.tsx new file mode 100644 index 000000000..ab3320dfe --- /dev/null +++ b/src/plugins/friendsSince/index.tsx @@ -0,0 +1,60 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findByPropsLazy } from "@webpack"; +import { React, RelationshipStore } from "@webpack/common"; + +const { Heading, Text } = findByPropsLazy("Heading", "Text"); +const container = findByPropsLazy("memberSinceContainer"); +const { getCreatedAtDate } = findByPropsLazy("getCreatedAtDate"); +const clydeMoreInfo = findByPropsLazy("clydeMoreInfo"); +const locale = findByPropsLazy("getLocale"); +const lastSection = findByPropsLazy("lastSection"); + +export default definePlugin({ + name: "FriendsSince", + description: "Shows when you became friends with someone in the user popout", + authors: [Devs.Elvyra], + patches: [ + { + find: ".AnalyticsSections.USER_PROFILE}", + replacement: { + match: /\i.default,\{userId:(\i.id).{0,30}}\)/, + replace: "$&,$self.friendsSince({ userId: $1 })" + } + }, + { + find: ".UserPopoutUpsellSource.PROFILE_PANEL,", + replacement: { + match: /\i.default,\{userId:(\i)}\)/, + replace: "$&,$self.friendsSince({ userId: $1 })" + } + } + ], + + friendsSince: ErrorBoundary.wrap(({ userId }: { userId: string; }) => { + const friendsSince = RelationshipStore.getSince(userId); + if (!friendsSince) return null; + + return ( +
+ + Friends Since + + +
+ + {getCreatedAtDate(friendsSince, locale.getLocale())} + +
+
+ ); + }, { noop: true }) +}); + diff --git a/src/utils/constants.ts b/src/utils/constants.ts index d213ce272..081eed34f 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -422,6 +422,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ Kyuuhachi: { name: "Kyuuhachi", id: 236588665420251137n, + }, + Elvyra: { + name: "Elvyra", + id: 708275751816003615n, } } satisfies Record);