From 19361ef7901bb016948324190f4c68783c63b780 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Sat, 18 Jan 2025 14:52:35 -0500 Subject: [PATCH 01/13] BadgeApi, AccountPanelServerProfile: Fix not working (#3147) --- src/plugins/_api/badges/index.tsx | 2 +- src/plugins/accountPanelServerProfile/index.tsx | 12 ++++++------ src/plugins/fullUserInChatbox/index.tsx | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/plugins/_api/badges/index.tsx b/src/plugins/_api/badges/index.tsx index d02b5e1d8..acdfb1f1f 100644 --- a/src/plugins/_api/badges/index.tsx +++ b/src/plugins/_api/badges/index.tsx @@ -79,7 +79,7 @@ export default definePlugin({ replace: "...$1.props,$& $1.image??" }, { - match: /(?<=text:(\i)\.description,.{0,200})children:/, + match: /(?<="aria-label":(\i)\.description,.{0,200})children:/, replace: "children:$1.component ? $self.renderBadgeComponent({ ...$1 }) :" }, // conditionally override their onClick with badge.onClick if it exists diff --git a/src/plugins/accountPanelServerProfile/index.tsx b/src/plugins/accountPanelServerProfile/index.tsx index 1b468a6d8..b6218bf54 100644 --- a/src/plugins/accountPanelServerProfile/index.tsx +++ b/src/plugins/accountPanelServerProfile/index.tsx @@ -16,7 +16,7 @@ import { User } from "discord-types/general"; interface UserProfileProps { popoutProps: Record; currentUser: User; - originalPopout: () => React.ReactNode; + OriginalPopout: () => React.ReactNode; } const UserProfile = findComponentByCodeLazy("UserProfilePopoutWrapper: user cannot be undefined"); @@ -73,12 +73,12 @@ export default definePlugin({ group: true, replacement: [ { - match: /(?<=\.SIZE_32\)}\);)/, + match: /(?<=\.AVATAR_SIZE\);)/, replace: "$self.useAccountPanelRef();" }, { match: /(\.AVATAR,children:.+?renderPopout:(\i)=>){(.+?)}(?=,position)(?<=currentUser:(\i).+?)/, - replace: (_, rest, popoutProps, originalPopout, currentUser) => `${rest}$self.UserProfile({popoutProps:${popoutProps},currentUser:${currentUser},originalPopout:()=>{${originalPopout}}})` + replace: (_, rest, popoutProps, originalPopout, currentUser) => `${rest}$self.UserProfile({popoutProps:${popoutProps},currentUser:${currentUser},OriginalPopout:()=>{${originalPopout}}})` }, { match: /\.AVATAR,children:.+?(?=renderPopout:)/, @@ -112,17 +112,17 @@ export default definePlugin({ openAlternatePopout = false; }, - UserProfile: ErrorBoundary.wrap(({ popoutProps, currentUser, originalPopout }: UserProfileProps) => { + UserProfile: ErrorBoundary.wrap(({ popoutProps, currentUser, OriginalPopout }: UserProfileProps) => { if ( (settings.store.prioritizeServerProfile && openAlternatePopout) || (!settings.store.prioritizeServerProfile && !openAlternatePopout) ) { - return originalPopout(); + return ; } const currentChannel = getCurrentChannel(); if (currentChannel?.getGuildId() == null) { - return originalPopout(); + return ; } return ( diff --git a/src/plugins/fullUserInChatbox/index.tsx b/src/plugins/fullUserInChatbox/index.tsx index 792f0419f..4bcc95b6c 100644 --- a/src/plugins/fullUserInChatbox/index.tsx +++ b/src/plugins/fullUserInChatbox/index.tsx @@ -16,7 +16,7 @@ interface UserMentionComponentProps { id: string; channelId: string; guildId: string; - OriginalComponent: ReactNode; + OriginalComponent: () => ReactNode; } export default definePlugin({ @@ -29,7 +29,7 @@ export default definePlugin({ find: ':"text":', replacement: { match: /(hidePersonalInformation\).+?)(if\(null!=\i\){.+?return \i)(?=})/, - replace: "$1return $self.UserMentionComponent({...arguments[0],OriginalComponent:(()=>{$2})()});" + replace: "$1return $self.UserMentionComponent({...arguments[0],OriginalComponent:()=>{$2}});" } } ], @@ -42,6 +42,6 @@ export default definePlugin({ channelId={props.channelId} /> ), { - fallback: ({ wrappedProps }) => wrappedProps.OriginalComponent + fallback: ({ wrappedProps: { OriginalComponent } }) => }) }); From 88e3bc037d0f6c366faf7897c16dbd4cad053dc0 Mon Sep 17 00:00:00 2001 From: Sqaaakoi Date: Sun, 19 Jan 2025 09:05:20 +1300 Subject: [PATCH 02/13] ConsoleShortcuts: Set FluxStore toStringTag to store name (#3144) --- src/plugins/consoleShortcuts/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/plugins/consoleShortcuts/index.ts b/src/plugins/consoleShortcuts/index.ts index 25d48f1d8..be23d37c3 100644 --- a/src/plugins/consoleShortcuts/index.ts +++ b/src/plugins/consoleShortcuts/index.ts @@ -179,6 +179,16 @@ export default definePlugin({ description: "Adds shorter Aliases for many things on the window. Run `shortcutList` for a list.", authors: [Devs.Ven], + patches: [ + { + find: 'this,"_changeCallbacks",', + replacement: { + match: /\i\(this,"_changeCallbacks",/, + replace: "Reflect.defineProperty(this,Symbol.toStringTag,{value:this.getName(),configurable:!0,writable:!0,enumerable:!1}),$&" + } + } + ], + startAt: StartAt.Init, start() { const shortcuts = makeShortcuts(); From a60af65b6d882ba48019d2f30e3bf43ac61377bf Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Sat, 18 Jan 2025 16:05:06 -0500 Subject: [PATCH 03/13] RevealAllSpoilers: Fix error on (#3149) --- src/plugins/revealAllSpoilers/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/revealAllSpoilers/index.ts b/src/plugins/revealAllSpoilers/index.ts index 98e8423cf..ead746b2b 100644 --- a/src/plugins/revealAllSpoilers/index.ts +++ b/src/plugins/revealAllSpoilers/index.ts @@ -21,7 +21,7 @@ import definePlugin from "@utils/types"; import { findByPropsLazy } from "@webpack"; const SpoilerClasses = findByPropsLazy("spoilerContent"); -const MessagesClasses = findByPropsLazy("messagesWrapper"); +const MessagesClasses = findByPropsLazy("messagesWrapper", "navigationDescription"); export default definePlugin({ name: "RevealAllSpoilers", From 47315b0eba933af9be555ca45e4e68a6ae5b6dd6 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 22 Jan 2025 18:11:13 +0100 Subject: [PATCH 04/13] fix plugins modifying message content --- src/plugins/_api/messageEvents.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/_api/messageEvents.ts b/src/plugins/_api/messageEvents.ts index 0101b02c8..97ed1746d 100644 --- a/src/plugins/_api/messageEvents.ts +++ b/src/plugins/_api/messageEvents.ts @@ -31,7 +31,7 @@ export default definePlugin({ replace: (match, args) => "" + `async ${match}` + `if(await Vencord.Api.MessageEvents._handlePreEdit(${args}))` + - "return Promise.resolve({shoudClear:true,shouldRefocus:true});" + "return Promise.resolve({shouldClear:false,shouldRefocus:true});" } }, { @@ -39,12 +39,12 @@ export default definePlugin({ replacement: { // props.chatInputType...then((function(isMessageValid)... var parsedMessage = b.c.parse(channel,... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); // Lookbehind: validateMessage)({openWarningPopout:..., type: i.props.chatInputType, content: t, stickers: r, ...}).then((function(isMessageValid) - match: /(type:this\.props\.chatInputType.+?\.then\()(\i=>\{.+?let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.getSendMessageOptionsForReply\(\i\);)(?<=\)\(({.+?})\)\.then.+?)/, + match: /(\{openWarningPopout:.{0,100}type:this.props.chatInputType.+?\.then\()(\i=>\{.+?let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.getSendMessageOptions\(\{.+?\}\);)(?<=\)\(({.+?})\)\.then.+?)/, // props.chatInputType...then((async function(isMessageValid)... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); if(await Vencord.api...) return { shoudClear:true, shouldRefocus:true }; replace: (_, rest1, rest2, parsedMessage, channel, replyOptions, extra) => "" + `${rest1}async ${rest2}` + `if(await Vencord.Api.MessageEvents._handlePreSend(${channel}.id,${parsedMessage},${extra},${replyOptions}))` + - "return{shoudClear:true,shouldRefocus:true};" + "return{shouldClear:false,shouldRefocus:true};" } }, { From 8346dba324b81672b120e1397ce1c70b18127abd Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 22 Jan 2025 15:07:33 -0300 Subject: [PATCH 05/13] SortFriendRequests: Fix showing dates --- src/plugins/sortFriendRequests/index.tsx | 33 ++++++++++++------------ 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/plugins/sortFriendRequests/index.tsx b/src/plugins/sortFriendRequests/index.tsx index 6ce1af14d..1bd382ba8 100644 --- a/src/plugins/sortFriendRequests/index.tsx +++ b/src/plugins/sortFriendRequests/index.tsx @@ -17,11 +17,17 @@ */ import { definePluginSettings } from "@api/Settings"; +import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { RelationshipStore } from "@webpack/common"; +import { RelationshipStore, Text } from "@webpack/common"; import { User } from "discord-types/general"; +import { PropsWithChildren } from "react"; + +function getSince(user: User) { + return new Date(RelationshipStore.getSince(user.id)); +} const settings = definePluginSettings({ showDates: { @@ -48,28 +54,23 @@ export default definePlugin({ find: "#{intl::FRIEND_REQUEST_CANCEL}", replacement: { predicate: () => settings.store.showDates, - match: /subText:(\i)(?<=user:(\i).+?)/, - replace: (_, subtext, user) => `subText:$self.makeSubtext(${subtext},${user})` + match: /(?<=\.listItemContents,children:\[)\(0,.+?(?=,\(0)(?<=user:(\i).+?)/, + replace: (children, user) => `$self.WrapperDateComponent({user:${user},children:${children}})` } }], wrapSort(comparator: Function, row: any) { return row.type === 3 || row.type === 4 - ? -this.getSince(row.user) + ? -getSince(row.user) : comparator(row); }, - getSince(user: User) { - return new Date(RelationshipStore.getSince(user.id)); - }, + WrapperDateComponent: ErrorBoundary.wrap(({ user, children }: PropsWithChildren<{ user: User; }>) => { + const since = getSince(user); - makeSubtext(text: string, user: User) { - const since = this.getSince(user); - return ( - - {text} - {!isNaN(since.getTime()) && Received — {since.toDateString()}} - - ); - } + return + {children} + {!isNaN(since.getTime()) && {since.toDateString()}} + ; + }) }); From 5312514de6078b6d9d2c733177056cc02ce25e66 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 22 Jan 2025 15:09:21 -0300 Subject: [PATCH 06/13] Bump to 1.11.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6113731d2..abb11ee5c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.10.9", + "version": "1.11.0", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { From 9bb983d40ca0bb7b815effa5c763b1e7ad9237bf Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 22 Jan 2025 20:01:33 +0100 Subject: [PATCH 07/13] SortFriendRequests: improve formatting & display --- src/plugins/replyTimestamp/index.tsx | 17 ++++++---------- src/plugins/sortFriendRequests/index.tsx | 24 ++++++++++++++++++----- src/plugins/sortFriendRequests/styles.css | 18 +++++++++++++++++ src/webpack/common/types/utils.d.ts | 7 +++++++ src/webpack/common/utils.ts | 7 +++++++ 5 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 src/plugins/sortFriendRequests/styles.css diff --git a/src/plugins/replyTimestamp/index.tsx b/src/plugins/replyTimestamp/index.tsx index dc31dd883..0be5dfec2 100644 --- a/src/plugins/replyTimestamp/index.tsx +++ b/src/plugins/replyTimestamp/index.tsx @@ -9,16 +9,11 @@ import "./style.css"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -import { filters, findByPropsLazy, mapMangledModuleLazy } from "@webpack"; -import { Timestamp } from "@webpack/common"; +import { findByPropsLazy } from "@webpack"; +import { DateUtils, Timestamp } from "@webpack/common"; import type { Message } from "discord-types/general"; import type { HTMLAttributes } from "react"; -const { calendarFormat, dateFormat, isSameDay } = mapMangledModuleLazy("millisecondsInUnit:", { - calendarFormat: filters.byCode("sameElse"), - dateFormat: filters.byCode('":'), - isSameDay: filters.byCode("Math.abs(+"), -}); const MessageClasses = findByPropsLazy("separator", "latin24CompactTimeStamp"); function Sep(props: HTMLAttributes) { @@ -46,14 +41,14 @@ function ReplyTimestamp({ return ( [ - {isSameDay(refTimestamp, baseTimestamp) - ? dateFormat(refTimestamp, "LT") - : calendarFormat(refTimestamp) + {DateUtils.isSameDay(refTimestamp, baseTimestamp) + ? DateUtils.dateFormat(refTimestamp, "LT") + : DateUtils.calendarFormat(refTimestamp) } ] diff --git a/src/plugins/sortFriendRequests/index.tsx b/src/plugins/sortFriendRequests/index.tsx index 1bd382ba8..5f45902e8 100644 --- a/src/plugins/sortFriendRequests/index.tsx +++ b/src/plugins/sortFriendRequests/index.tsx @@ -16,15 +16,25 @@ * along with this program. If not, see . */ +import "./styles.css"; + import { definePluginSettings } from "@api/Settings"; +import { classNameFactory } from "@api/Styles"; import ErrorBoundary from "@components/ErrorBoundary"; -import { Flex } from "@components/Flex"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { RelationshipStore, Text } from "@webpack/common"; +import { DateUtils, RelationshipStore, Text, TooltipContainer } from "@webpack/common"; import { User } from "discord-types/general"; import { PropsWithChildren } from "react"; +const formatter = new Intl.DateTimeFormat(undefined, { + month: "numeric", + day: "numeric", + year: "numeric", +}); + +const cl = classNameFactory("vc-sortFriendRequests-"); + function getSince(user: User) { return new Date(RelationshipStore.getSince(user.id)); } @@ -68,9 +78,13 @@ export default definePlugin({ WrapperDateComponent: ErrorBoundary.wrap(({ user, children }: PropsWithChildren<{ user: User; }>) => { const since = getSince(user); - return + return
{children} - {!isNaN(since.getTime()) && {since.toDateString()}} - ; + {!isNaN(since.getTime()) && ( + + {formatter.format(since)} + + )} +
; }) }); diff --git a/src/plugins/sortFriendRequests/styles.css b/src/plugins/sortFriendRequests/styles.css new file mode 100644 index 000000000..98be9da7c --- /dev/null +++ b/src/plugins/sortFriendRequests/styles.css @@ -0,0 +1,18 @@ +.vc-sortFriendRequests-wrapper { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + width: 100%; + margin-right: 0.5em; +} + +.vc-sortFriendRequests-tooltip { + max-width: none; + white-space: nowrap; +} + +.vc-sortFriendRequests-date { + color: var(--text-muted); + font-family: var(--font-code); +} diff --git a/src/webpack/common/types/utils.d.ts b/src/webpack/common/types/utils.d.ts index 00e3f4a0b..de1ce1829 100644 --- a/src/webpack/common/types/utils.d.ts +++ b/src/webpack/common/types/utils.d.ts @@ -324,3 +324,10 @@ export interface DisplayProfileUtils { getDisplayProfile(userId: string, guildId?: string, customStores?: any): DisplayProfile | null; useDisplayProfile(userId: string, guildId?: string, customStores?: any): DisplayProfile | null; } + +export interface DateUtils { + isSameDay(date1: Date, date2: Date): boolean; + calendarFormat(date: Date): string; + dateFormat(date: Date, format: string): string; + diffAsUnits(start: Date, end: Date, stopAtOneSecond?: boolean): Record<"days" | "hours" | "minutes" | "seconds", number>; +} diff --git a/src/webpack/common/utils.ts b/src/webpack/common/utils.ts index 3699300b6..1bdf236ac 100644 --- a/src/webpack/common/utils.ts +++ b/src/webpack/common/utils.ts @@ -199,3 +199,10 @@ export const DisplayProfileUtils: t.DisplayProfileUtils = mapMangledModuleLazy(/ getDisplayProfile: filters.byCode(".getGuildMemberProfile("), useDisplayProfile: filters.byCode(/\[\i\.\i,\i\.\i],\(\)=>/) }); + +export const DateUtils: t.DateUtils = mapMangledModuleLazy("millisecondsInUnit:", { + calendarFormat: filters.byCode("sameElse"), + dateFormat: filters.byCode('":'), + isSameDay: filters.byCode("Math.abs(+"), + diffAsUnits: filters.byCode("days:0", "millisecondsInUnit") +}); From 9e9d71d014a185bbdf990a545be4870d36c1b3b9 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 22 Jan 2025 17:40:47 -0300 Subject: [PATCH 08/13] AccountPanelServerProfile: Fix buttons unusable and request spam --- src/plugins/accountPanelServerProfile/index.tsx | 10 +++++----- src/plugins/fullUserInChatbox/index.tsx | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/accountPanelServerProfile/index.tsx b/src/plugins/accountPanelServerProfile/index.tsx index b6218bf54..e2dc220b7 100644 --- a/src/plugins/accountPanelServerProfile/index.tsx +++ b/src/plugins/accountPanelServerProfile/index.tsx @@ -16,7 +16,7 @@ import { User } from "discord-types/general"; interface UserProfileProps { popoutProps: Record; currentUser: User; - OriginalPopout: () => React.ReactNode; + originalRenderPopout: () => React.ReactNode; } const UserProfile = findComponentByCodeLazy("UserProfilePopoutWrapper: user cannot be undefined"); @@ -78,7 +78,7 @@ export default definePlugin({ }, { match: /(\.AVATAR,children:.+?renderPopout:(\i)=>){(.+?)}(?=,position)(?<=currentUser:(\i).+?)/, - replace: (_, rest, popoutProps, originalPopout, currentUser) => `${rest}$self.UserProfile({popoutProps:${popoutProps},currentUser:${currentUser},OriginalPopout:()=>{${originalPopout}}})` + replace: (_, rest, popoutProps, originalPopout, currentUser) => `${rest}$self.UserProfile({popoutProps:${popoutProps},currentUser:${currentUser},originalRenderPopout:()=>{${originalPopout}}})` }, { match: /\.AVATAR,children:.+?(?=renderPopout:)/, @@ -112,17 +112,17 @@ export default definePlugin({ openAlternatePopout = false; }, - UserProfile: ErrorBoundary.wrap(({ popoutProps, currentUser, OriginalPopout }: UserProfileProps) => { + UserProfile: ErrorBoundary.wrap(({ popoutProps, currentUser, originalRenderPopout }: UserProfileProps) => { if ( (settings.store.prioritizeServerProfile && openAlternatePopout) || (!settings.store.prioritizeServerProfile && !openAlternatePopout) ) { - return ; + return originalRenderPopout(); } const currentChannel = getCurrentChannel(); if (currentChannel?.getGuildId() == null) { - return ; + return originalRenderPopout(); } return ( diff --git a/src/plugins/fullUserInChatbox/index.tsx b/src/plugins/fullUserInChatbox/index.tsx index 4bcc95b6c..5a0c41c01 100644 --- a/src/plugins/fullUserInChatbox/index.tsx +++ b/src/plugins/fullUserInChatbox/index.tsx @@ -16,7 +16,7 @@ interface UserMentionComponentProps { id: string; channelId: string; guildId: string; - OriginalComponent: () => ReactNode; + originalComponent: () => ReactNode; } export default definePlugin({ @@ -29,7 +29,7 @@ export default definePlugin({ find: ':"text":', replacement: { match: /(hidePersonalInformation\).+?)(if\(null!=\i\){.+?return \i)(?=})/, - replace: "$1return $self.UserMentionComponent({...arguments[0],OriginalComponent:()=>{$2}});" + replace: "$1return $self.UserMentionComponent({...arguments[0],originalComponent:()=>{$2}});" } } ], @@ -42,6 +42,6 @@ export default definePlugin({ channelId={props.channelId} /> ), { - fallback: ({ wrappedProps: { OriginalComponent } }) => + fallback: ({ wrappedProps: { originalComponent } }) => originalComponent() }) }); From ea0182a194d22f7caf05bfbda9fcb68f03cc56aa Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 22 Jan 2025 18:03:51 -0300 Subject: [PATCH 09/13] Fix BetterUploadButton & FixImagesQuality --- src/plugins/betterUploadButton/index.ts | 2 +- src/plugins/fixImagesQuality/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/betterUploadButton/index.ts b/src/plugins/betterUploadButton/index.ts index 2406b71e5..c08d43282 100644 --- a/src/plugins/betterUploadButton/index.ts +++ b/src/plugins/betterUploadButton/index.ts @@ -27,7 +27,7 @@ export default definePlugin({ { find: '"ChannelAttachButton"', replacement: { - match: /\.attachButtonInner,"aria-label":.{0,50},onDoubleClick:(.+?:void 0),\.\.\.(\i),/, + match: /\.attachButtonInner,"aria-label":.{0,50},onDoubleClick:(.+?:void 0),.{0,30}?\.\.\.(\i),/, replace: "$&onClick:$1,onContextMenu:$2.onClick,", }, }, diff --git a/src/plugins/fixImagesQuality/index.ts b/src/plugins/fixImagesQuality/index.ts index 8f84573c0..b62d3c7bc 100644 --- a/src/plugins/fixImagesQuality/index.ts +++ b/src/plugins/fixImagesQuality/index.ts @@ -13,7 +13,7 @@ export default definePlugin({ authors: [Devs.Nuckyz], patches: [ { - find: "getFormatQuality(){", + find: ".handleImageLoad)", replacement: { match: /(?<=null;return )\i\.\i&&\(\i\|\|!\i\.isAnimated.+?:(?=\i&&\(\i="png"\))/, replace: "" From 17f1ef275ef52c8ab539f528247df50022d81550 Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Thu, 23 Jan 2025 07:33:11 +0700 Subject: [PATCH 10/13] CustomRPC: improve rich presence preview & UX (#3159) Co-authored-by: Vendicated --- src/plugins/customRPC/index.tsx | 57 ++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/src/plugins/customRPC/index.tsx b/src/plugins/customRPC/index.tsx index f4b9ab060..64aea76aa 100644 --- a/src/plugins/customRPC/index.tsx +++ b/src/plugins/customRPC/index.tsx @@ -19,6 +19,7 @@ import { definePluginSettings, Settings } from "@api/Settings"; import { getUserSettingLazy } from "@api/UserSettings"; import { ErrorCard } from "@components/ErrorCard"; +import { Flex } from "@components/Flex"; import { Link } from "@components/Link"; import { Devs } from "@utils/constants"; import { isTruthy } from "@utils/guards"; @@ -27,15 +28,14 @@ import { classes } from "@utils/misc"; import { useAwaiter } from "@utils/react"; import definePlugin, { OptionType } from "@utils/types"; import { findByCodeLazy, findComponentByCodeLazy } from "@webpack"; -import { ApplicationAssetUtils, Button, FluxDispatcher, Forms, GuildStore, React, SelectedChannelStore, SelectedGuildStore, UserStore } from "@webpack/common"; +import { ApplicationAssetUtils, Button, FluxDispatcher, Forms, React, UserStore } from "@webpack/common"; const useProfileThemeStyle = findByCodeLazy("profileThemeStyle:", "--profile-gradient-primary-color"); -const ActivityComponent = findComponentByCodeLazy("onOpenGameProfile"); +const ActivityView = findComponentByCodeLazy('location:"UserProfileActivityCard",'); const ShowCurrentGame = getUserSettingLazy("status", "showCurrentGame")!; async function getApplicationAsset(key: string): Promise { - if (/https?:\/\/(cdn|media)\.discordapp\.(com|net)\/attachments\//.test(key)) return "mp:" + key.replace(/https?:\/\/(cdn|media)\.discordapp\.(com|net)\//, ""); return (await ApplicationAssetUtils.fetchAssetIds(settings.store.appID!, [key]))[0]; } @@ -169,7 +169,7 @@ const settings = definePluginSettings({ value: TimestampMode.NOW }, { - label: "Same as your current time", + label: "Same as your current time (not reset after 24h)", value: TimestampMode.TIME }, { @@ -269,6 +269,7 @@ function isStreamLinkDisabled() { function isStreamLinkValid(value: string) { if (!isStreamLinkDisabled() && !/https?:\/\/(www\.)?(twitch\.tv|youtube\.com)\/\w+/.test(value)) return "Streaming link must be a valid URL."; + if (value && value.length > 512) return "Streaming link must be not longer than 512 characters."; return true; } @@ -277,8 +278,9 @@ function isTimestampDisabled() { } function isImageKeyValid(value: string) { - if (/https?:\/\/(?!i\.)?imgur\.com\//.test(value)) return "Imgur link must be a direct link to the image. (e.g. https://i.imgur.com/...)"; - if (/https?:\/\/(?!media\.)?tenor\.com\//.test(value)) return "Tenor link must be a direct link to the image. (e.g. https://media.tenor.com/...)"; + if (/https?:\/\/(cdn|media)\.discordapp\.(com|net)\//.test(value)) return "Don't use a Discord link. Use an Imgur image link instead."; + if (/https?:\/\/(?!i\.)?imgur\.com\//.test(value)) return "Imgur link must be a direct link to the image (e.g. https://i.imgur.com/...). Right click the image and click 'Copy image address'"; + if (/https?:\/\/(?!media\.)?tenor\.com\//.test(value)) return "Tenor link must be a direct link to the image (e.g. https://media.tenor.com/...). Right click the GIF and click 'Copy image address'"; return true; } @@ -390,7 +392,7 @@ async function setRpc(disable?: boolean) { export default definePlugin({ name: "CustomRPC", - description: "Allows you to set a custom rich presence.", + description: "Add a fully customisable Rich Presence (Game status) to your Discord profile", authors: [Devs.captain, Devs.AutumnVN, Devs.nin0dev], dependencies: ["UserSettingsAPI"], start: setRpc, @@ -410,7 +412,7 @@ export default definePlugin({ style={{ padding: "1em" }} > Notice - Game activity isn't enabled, people won't be able to see your custom rich presence! + Activity Sharing isn't enabled, people won't be able to see your custom rich presence!