diff --git a/package.json b/package.json index 65a2f4512..e65e1b0a7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.9.9", + "version": "1.10.1", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { diff --git a/src/api/Commands/index.ts b/src/api/Commands/index.ts index 5e3fc8f4d..e5803ba02 100644 --- a/src/api/Commands/index.ts +++ b/src/api/Commands/index.ts @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import { Logger } from "@utils/Logger"; import { makeCodeblock } from "@utils/text"; import { sendBotMessage } from "./commandHelpers"; @@ -46,10 +47,10 @@ export let RequiredMessageOption: Option = ReqPlaceholder; export const _init = function (cmds: Command[]) { try { BUILT_IN = cmds; - OptionalMessageOption = cmds.find(c => c.name === "shrug")!.options![0]; - RequiredMessageOption = cmds.find(c => c.name === "me")!.options![0]; + OptionalMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "shrug")!.options![0]; + RequiredMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "me")!.options![0]; } catch (e) { - console.error("Failed to load CommandsApi"); + new Logger("CommandsAPI").error("Failed to load CommandsApi", e, " - cmds is", cmds); } return cmds; } as never; diff --git a/src/plugins/_api/badges/fixBadgeOverflow.css b/src/plugins/_api/badges/fixBadgeOverflow.css deleted file mode 100644 index 348d0ff38..000000000 --- a/src/plugins/_api/badges/fixBadgeOverflow.css +++ /dev/null @@ -1,3 +0,0 @@ -[class*="profileBadges"] { - flex: none; -} diff --git a/src/plugins/_api/badges/index.tsx b/src/plugins/_api/badges/index.tsx index cf00a0e29..c44d98b90 100644 --- a/src/plugins/_api/badges/index.tsx +++ b/src/plugins/_api/badges/index.tsx @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -import "./fixBadgeOverflow.css"; - import { _getBadges, BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges"; import DonateButton from "@components/DonateButton"; import ErrorBoundary from "@components/ErrorBoundary"; @@ -79,7 +77,7 @@ export default definePlugin({ replace: "...$1.props,$& $1.image??" }, { - match: /(?<=text:(\i)\.description,.{0,50})children:/, + match: /(?<=text:(\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/_core/noTrack.ts b/src/plugins/_core/noTrack.ts index de1c20562..8d6a1e76d 100644 --- a/src/plugins/_core/noTrack.ts +++ b/src/plugins/_core/noTrack.ts @@ -48,7 +48,7 @@ export default definePlugin({ }, }, { - find: ".METRICS,", + find: ".METRICS", replacement: [ { match: /this\._intervalId=/, diff --git a/src/plugins/accountPanelServerProfile/README.md b/src/plugins/accountPanelServerProfile/README.md new file mode 100644 index 000000000..f837864b7 --- /dev/null +++ b/src/plugins/accountPanelServerProfile/README.md @@ -0,0 +1,7 @@ +# AccountPanelServerProfile + +Right click your account panel in the bottom left to view your profile in the current server + +![](https://github.com/user-attachments/assets/3228497d-488f-479c-93d2-a32ccdb08f0f) + +![](https://github.com/user-attachments/assets/6fc45363-d95f-4810-812f-2f9fb28b41b5) diff --git a/src/plugins/accountPanelServerProfile/index.tsx b/src/plugins/accountPanelServerProfile/index.tsx new file mode 100644 index 000000000..fe5df48ad --- /dev/null +++ b/src/plugins/accountPanelServerProfile/index.tsx @@ -0,0 +1,134 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { definePluginSettings } from "@api/Settings"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import { getCurrentChannel } from "@utils/discord"; +import definePlugin, { OptionType } from "@utils/types"; +import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; +import { ContextMenuApi, Menu, useEffect, useRef } from "@webpack/common"; +import { User } from "discord-types/general"; + +interface UserProfileProps { + popoutProps: Record; + currentUser: User; + originalPopout: () => React.ReactNode; +} + +const UserProfile = findComponentByCodeLazy("UserProfilePopoutWrapper: user cannot be undefined"); +const styles = findByPropsLazy("accountProfilePopoutWrapper"); + +let openAlternatePopout = false; +let accountPanelRef: React.MutableRefObject | null> = { current: null }; + +const AccountPanelContextMenu = ErrorBoundary.wrap(() => { + const { prioritizeServerProfile } = settings.use(["prioritizeServerProfile"]); + + return ( + + { + openAlternatePopout = true; + accountPanelRef.current?.props.onMouseDown(); + accountPanelRef.current?.props.onClick(e); + }} + /> + settings.store.prioritizeServerProfile = !prioritizeServerProfile} + /> + + ); +}, { noop: true }); + +const settings = definePluginSettings({ + prioritizeServerProfile: { + type: OptionType.BOOLEAN, + description: "Prioritize Server Profile when left clicking your account panel", + default: false + } +}); + +export default definePlugin({ + name: "AccountPanelServerProfile", + description: "Right click your account panel in the bottom left to view your profile in the current server", + authors: [Devs.Nuckyz, Devs.relitrix], + settings, + + patches: [ + { + find: ".Messages.ACCOUNT_SPEAKING_WHILE_MUTED", + group: true, + replacement: [ + { + match: /(?<=\.SIZE_32\)}\);)/, + 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}}})` + }, + { + match: /\.AVATAR,children:.+?(?=renderPopout:)/, + replace: "$&onRequestClose:$self.onPopoutClose," + }, + { + match: /(?<=.avatarWrapper,)/, + replace: "ref:$self.accountPanelRef,onContextMenu:$self.openAccountPanelContextMenu," + } + ] + } + ], + + get accountPanelRef() { + return accountPanelRef; + }, + + useAccountPanelRef() { + useEffect(() => () => { + accountPanelRef.current = null; + }, []); + + return (accountPanelRef = useRef(null)); + }, + + openAccountPanelContextMenu(event: React.UIEvent) { + ContextMenuApi.openContextMenu(event, AccountPanelContextMenu); + }, + + onPopoutClose() { + openAlternatePopout = false; + }, + + UserProfile: ErrorBoundary.wrap(({ popoutProps, currentUser, originalPopout }: UserProfileProps) => { + if ( + (settings.store.prioritizeServerProfile && openAlternatePopout) || + (!settings.store.prioritizeServerProfile && !openAlternatePopout) + ) { + return originalPopout(); + } + + const currentChannel = getCurrentChannel(); + if (currentChannel?.getGuildId() == null) { + return originalPopout(); + } + + return ( +
+ +
+ ); + }, { noop: true }) +}); diff --git a/src/plugins/appleMusic.desktop/index.tsx b/src/plugins/appleMusic.desktop/index.tsx index 6fa989cdd..327fafc30 100644 --- a/src/plugins/appleMusic.desktop/index.tsx +++ b/src/plugins/appleMusic.desktop/index.tsx @@ -120,7 +120,7 @@ const settings = definePluginSettings({ stateString: { type: OptionType.STRING, description: "Activity state format string", - default: "{artist}" + default: "{artist} ยท {album}" }, largeImageType: { type: OptionType.SELECT, diff --git a/src/plugins/appleMusic.desktop/native.ts b/src/plugins/appleMusic.desktop/native.ts index 2eb2a0757..7d69a85ae 100644 --- a/src/plugins/appleMusic.desktop/native.ts +++ b/src/plugins/appleMusic.desktop/native.ts @@ -11,37 +11,11 @@ import type { TrackData } from "."; const exec = promisify(execFile); -// function exec(file: string, args: string[] = []) { -// return new Promise<{ code: number | null, stdout: string | null, stderr: string | null; }>((resolve, reject) => { -// const process = spawn(file, args, { stdio: [null, "pipe", "pipe"] }); - -// let stdout: string | null = null; -// process.stdout.on("data", (chunk: string) => { stdout ??= ""; stdout += chunk; }); -// let stderr: string | null = null; -// process.stderr.on("data", (chunk: string) => { stdout ??= ""; stderr += chunk; }); - -// process.on("exit", code => { resolve({ code, stdout, stderr }); }); -// process.on("error", err => reject(err)); -// }); -// } - async function applescript(cmds: string[]) { const { stdout } = await exec("osascript", cmds.map(c => ["-e", c]).flat()); return stdout; } -function makeSearchUrl(type: string, query: string) { - const url = new URL("https://tools.applemediaservices.com/api/apple-media/music/US/search.json"); - url.searchParams.set("types", type); - url.searchParams.set("limit", "1"); - url.searchParams.set("term", query); - return url; -} - -const requestOptions: RequestInit = { - headers: { "user-agent": "Mozilla/5.0 (Windows NT 10.0; rv:125.0) Gecko/20100101 Firefox/125.0" }, -}; - interface RemoteData { appleMusicLink?: string, songLink?: string, @@ -51,6 +25,24 @@ interface RemoteData { let cachedRemoteData: { id: string, data: RemoteData; } | { id: string, failures: number; } | null = null; +const APPLE_MUSIC_BUNDLE_REGEX = /