diff --git a/src/equicordplugins/hideServers/components/HiddenServersButton.tsx b/src/equicordplugins/hideServers/components/HiddenServersButton.tsx index 12b5770f..9cad8482 100644 --- a/src/equicordplugins/hideServers/components/HiddenServersButton.tsx +++ b/src/equicordplugins/hideServers/components/HiddenServersButton.tsx @@ -8,6 +8,7 @@ import "./style.css"; import { classNameFactory } from "@api/Styles"; import { Button, ButtonLooks, GuildStore, useStateFromStores } from "@webpack/common"; + import { HiddenServersStore } from "../HiddenServersStore"; import { openHiddenServersModal } from "./HiddenServersMenu"; diff --git a/src/equicordplugins/hideServers/components/HiddenServersMenu.tsx b/src/equicordplugins/hideServers/components/HiddenServersMenu.tsx index e2b89aff..2673e1d4 100644 --- a/src/equicordplugins/hideServers/components/HiddenServersMenu.tsx +++ b/src/equicordplugins/hideServers/components/HiddenServersMenu.tsx @@ -17,7 +17,7 @@ import { openModal, } from "@utils/modal"; import { findByPropsLazy } from "@webpack"; -import { Button, Forms, IconUtils, Text, useState, useStateFromStores } from "@webpack/common"; +import { Button, Forms, IconUtils, Text, useStateFromStores } from "@webpack/common"; import { Guild } from "discord-types/general"; import { HiddenServersStore } from "../HiddenServersStore"; @@ -91,7 +91,7 @@ export function HiddenServersMenu({ servers }: { servers: Guild[]; }) { )} ; -}; +} export function openHiddenServersModal() { const key = openModal(modalProps => { diff --git a/src/plugins/accountPanelServerProfile/README.md b/src/plugins/accountPanelServerProfile/README.md new file mode 100644 index 00000000..f837864b --- /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 00000000..fe5df48a --- /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/biggerStreamPreview/index.tsx b/src/plugins/biggerStreamPreview/index.tsx index a86e3fca..8cca912b 100644 --- a/src/plugins/biggerStreamPreview/index.tsx +++ b/src/plugins/biggerStreamPreview/index.tsx @@ -88,7 +88,7 @@ export const userContextPatch: NavContextMenuPatchCallback = (children, { user } export default definePlugin({ name: "BiggerStreamPreview", description: "This plugin allows you to enlarge stream previews", - authors: [Devs.philhk], + authors: [Devs.phil], contextMenus: { "user-context": userContextPatch, "stream-context": streamContextPatch diff --git a/src/plugins/userVoiceShow/index.tsx b/src/plugins/userVoiceShow/index.tsx index 49762b99..4751421f 100644 --- a/src/plugins/userVoiceShow/index.tsx +++ b/src/plugins/userVoiceShow/index.tsx @@ -19,7 +19,7 @@ import "./styles.css"; import ErrorBoundary from "@components/ErrorBoundary"; -import { Devs } from "@utils/constants"; +import { Devs, EquicordDevs } from "@utils/constants"; import definePlugin from "@utils/types"; import VoiceActivityIcon from "./components/VoiceActivityIcon"; @@ -29,7 +29,7 @@ import { VoiceActivityProps } from "./types"; export default definePlugin({ name: "UserVoiceShow", description: "Shows users' voice activity information in profiles and members lists", - authors: [Devs.LordElias, Devs.llytz], + authors: [Devs.LordElias, EquicordDevs.llytz], tags: ["voice", "activity"], settings, diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 90e57f88..3cb1b365 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -321,8 +321,8 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "amia", id: 142007603549962240n }, - philhk: { - name: "philhk", + phil: { + name: "phil", id: 305288513941667851n }, ImLvna: { @@ -523,7 +523,7 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, nyx: { name: "verticalsync", - id: 1207087393929171095n + id: 328165170536775680n }, nekohaxx: { name: "nekohaxx", @@ -557,9 +557,9 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "Lumap", id: 585278686291427338n, }, - llytz: { - name: "llytz", - id: 1271128098301022240n + Obsidian: { + name: "Obsidian", + id: 683171006717755446n, }, SerStars: { name: "SerStars", @@ -569,9 +569,9 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "niko", id: 341377368075796483n, }, - Obsidian: { - name: "Obsidian", - id: 683171006717755446n, + relitrix: { + name: "Relitrix", + id: 423165393901715456n, }, RamziAH: { name: "RamziAH", @@ -791,7 +791,11 @@ export const EquicordDevs = Object.freeze({ bep: { name: "bep", id: 0n, - } + }, + llytz: { + name: "llytz", + id: 1271128098301022240n + }, } satisfies Record); // iife so #__PURE__ works correctly