From 21b3af6308a3962f9c68a97d4ba4951a3b1089b8 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Thu, 22 Aug 2024 11:43:13 -0400 Subject: [PATCH] Reverts --- src/plugins/showConnections/index.tsx | 8 ++ .../components/VoiceChannelSection.css | 27 +++++ .../components/VoiceChannelSection.tsx | 61 ++++++++++ src/plugins/userVoiceShow/index.tsx | 114 ++++++++++++++++++ 4 files changed, 210 insertions(+) create mode 100644 src/plugins/userVoiceShow/components/VoiceChannelSection.css create mode 100644 src/plugins/userVoiceShow/components/VoiceChannelSection.tsx create mode 100644 src/plugins/userVoiceShow/index.tsx diff --git a/src/plugins/showConnections/index.tsx b/src/plugins/showConnections/index.tsx index 440e76a8..4c9becde 100644 --- a/src/plugins/showConnections/index.tsx +++ b/src/plugins/showConnections/index.tsx @@ -188,6 +188,14 @@ export default definePlugin({ description: "Show connected accounts in user popouts", authors: [Devs.TheKodeToad], patches: [ + { + find: ".PROFILE_PANEL,", + replacement: { + // createElement(Divider, {}), createElement(NoteComponent) + match: /\(0,\i\.jsx\)\(\i\.\i,\{\}\).{0,100}setNote:(?=.+?channelId:(\i).id)/, + replace: "$self.profilePanelComponent({ id: $1.recipients[0] }),$&" + } + }, { find: '"BiteSizeProfileBody"', replacement: { diff --git a/src/plugins/userVoiceShow/components/VoiceChannelSection.css b/src/plugins/userVoiceShow/components/VoiceChannelSection.css new file mode 100644 index 00000000..00ecf5d4 --- /dev/null +++ b/src/plugins/userVoiceShow/components/VoiceChannelSection.css @@ -0,0 +1,27 @@ +.vc-uvs-button>div { + white-space: normal !important; +} + +.vc-uvs-button { + width: 100%; + margin: auto; + height: unset; +} + +.vc-uvs-header { + color: var(--header-primary); + margin-bottom: 6px; +} + +.vc-uvs-modal-margin { + margin: 0 12px; +} + +.vc-uvs-modal-margin div { + margin-bottom: 0 !important; +} + +.vc-uvs-popout-margin-self>[class^="section"] { + padding-top: 0; + padding-bottom: 12px; +} diff --git a/src/plugins/userVoiceShow/components/VoiceChannelSection.tsx b/src/plugins/userVoiceShow/components/VoiceChannelSection.tsx new file mode 100644 index 00000000..c1bcbd65 --- /dev/null +++ b/src/plugins/userVoiceShow/components/VoiceChannelSection.tsx @@ -0,0 +1,61 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2023 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import "./VoiceChannelSection.css"; + +import { findByCodeLazy, findByPropsLazy } from "@webpack"; +import { Button, Forms, PermissionStore, Toasts } from "@webpack/common"; +import { Channel } from "discord-types/general"; + +const ChannelActions = findByPropsLazy("selectChannel", "selectVoiceChannel"); +const UserPopoutSection = findByCodeLazy(".lastSection", "children:"); + +const CONNECT = 1n << 20n; + +interface VoiceChannelFieldProps { + channel: Channel; + label: string; + showHeader: boolean; +} + +export const VoiceChannelSection = ({ channel, label, showHeader }: VoiceChannelFieldProps) => ( + + {showHeader && In a voice channel} + + +); diff --git a/src/plugins/userVoiceShow/index.tsx b/src/plugins/userVoiceShow/index.tsx new file mode 100644 index 00000000..7d640171 --- /dev/null +++ b/src/plugins/userVoiceShow/index.tsx @@ -0,0 +1,114 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2023 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { definePluginSettings } from "@api/Settings"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { findStoreLazy } from "@webpack"; +import { ChannelStore, GuildStore, UserStore } from "@webpack/common"; +import { User } from "discord-types/general"; + +import { VoiceChannelSection } from "./components/VoiceChannelSection"; + +const VoiceStateStore = findStoreLazy("VoiceStateStore"); + +const settings = definePluginSettings({ + showInUserProfileModal: { + type: OptionType.BOOLEAN, + description: "Show a user's voice channel in their profile modal", + default: true, + }, + showVoiceChannelSectionHeader: { + type: OptionType.BOOLEAN, + description: 'Whether to show "IN A VOICE CHANNEL" above the join button', + default: true, + } +}); + +interface UserProps { + user: User; +} + +const VoiceChannelField = ErrorBoundary.wrap(({ user }: UserProps) => { + const { channelId } = VoiceStateStore.getVoiceStateForUser(user.id) ?? {}; + if (!channelId) return null; + + const channel = ChannelStore.getChannel(channelId); + if (!channel) return null; + + const guild = GuildStore.getGuild(channel.guild_id); + + if (!guild) return null; // When in DM call + + const result = `${guild.name} | ${channel.name}`; + + return ( + + ); +}); + +export default definePlugin({ + name: "UserVoiceShow", + description: "Shows whether a User is currently in a voice channel somewhere in their profile", + authors: [Devs.LordElias], + settings, + + patchModal({ user }: UserProps) { + if (!settings.store.showInUserProfileModal) + return null; + + return ( +
+ +
+ ); + }, + + patchPopout: ({ user }: UserProps) => { + const isSelfUser = user.id === UserStore.getCurrentUser().id; + return ( +
+ +
+ ); + }, + + patches: [ + // above message box + { + find: ".popularApplicationCommandIds,", + replacement: { + match: /(?<=,)(?=!\i&&!\i&&.{0,50}setNote:)/, + replace: "$self.patchPopout(arguments[0]),", + } + }, + // below username + { + find: ".Messages.MUTUAL_GUILDS_WITH_END_COUNT", // Lazy Loaded + replacement: { + match: /\.body.+?displayProfile:\i}\),/, + replace: "$&$self.patchModal(arguments[0]),", + } + } + ], +});