From 3e58b70b98859e1ac89b6784bf8b4b67a7afe8c8 Mon Sep 17 00:00:00 2001 From: Cooper Date: Sat, 29 Jun 2024 23:58:29 -0500 Subject: [PATCH] Switch to patch-only soulution --- src/plugins/openMoreConnections/index.ts | 45 ++++++++---------------- src/plugins/showConnections/index.tsx | 2 +- 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/src/plugins/openMoreConnections/index.ts b/src/plugins/openMoreConnections/index.ts index aa5ceb617..e69708844 100644 --- a/src/plugins/openMoreConnections/index.ts +++ b/src/plugins/openMoreConnections/index.ts @@ -7,8 +7,6 @@ import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; - - //* platforms that dont open //* riot and leage (can't view profiles) //* epic (can't view profiles) @@ -17,43 +15,28 @@ import definePlugin from "@utils/types"; //* xbox //* battle.net (can't view profiles) -enum ConnectionType { - Roblox = "roblox", - PSN = "playstation", - Xbox = "xbox", -} - - -interface Connection { - type: ConnectionType | string; - id: string; - name: string; - verified: boolean; -} - - +const uris = { // name = t, and id = l + roblox: "https://www.roblox.com/users/${l}/profile", + xbox: "https://www.xbox.com/play/user/${t}" +}; export default definePlugin({ name: "OpenMoreConnections", description: "Adds the Open Profile button to connections that don't natively have it in the regular Discord client. Supported Platforms: Xbox, and Roblox. Planned Platforms: PSN. Platforms that will never be supported: Riot Games/League of Legends, Battle.net, and Epic Games", authors: [Devs.coopeeo], patches: [ { - find: ".CONNECTED_ACCOUNT_VIEWED,", + find: "getPlatformUserUrl:e=>", replacement: { - match: /(?<=(\i)=null==\i\?void 0:null===\(\i=\i.getPlatformUserUrl\)\|\|void 0===\i\?void 0:\i.call\(\i,(\i)\);)/, - replace: "if ($1 == null) $1 = $self.addConnectionLink($2);" + match: /(?<=Roblox",.*},.+)(?=},)/, + replace: `, getPlatformUserUrl:e=>{let {name:t, id:l} = e; return \`${uris.roblox}\`;}` + } + }, + { + find: "getPlatformUserUrl:e=>", + replacement: { + match: /(?<=Xbox",.*},.+)(?=},)/, + replace: `, getPlatformUserUrl:e=>{let {name:t, id:l} = e; return \`${uris.xbox}\`;}` } } ], - addConnectionLink(con: Connection) { - switch (con.type) { - case ConnectionType.Roblox: - return `https://www.roblox.com/users/${con.id}/profile`; - case ConnectionType.Xbox: - return `https://www.xbox.com/play/user/${con.name}`; - } - - - return null; - } }); diff --git a/src/plugins/showConnections/index.tsx b/src/plugins/showConnections/index.tsx index d45a2e11e..d6909dc91 100644 --- a/src/plugins/showConnections/index.tsx +++ b/src/plugins/showConnections/index.tsx @@ -134,7 +134,7 @@ function ConnectionsComponent({ id, theme, simplified }: { id: string, theme: st function CompactConnectionComponent({ connection, theme }: { connection: Connection, theme: string; }) { const platform = platforms.get(useLegacyPlatformType(connection.type)); - var url = platform.getPlatformUserUrl?.(connection); + const url = platform.getPlatformUserUrl?.(connection); const img = (