From 9dc706c45fe7397c917a2b82598e93c7e1144c06 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Tue, 25 Mar 2025 00:16:30 -0400 Subject: [PATCH] Revert "Add files via upload" This reverts commit 7b0c9f2d5dfe3528e5a58546bc2807b9b4e49ad6. --- src/equicordplugins/randomVoice/index.tsx | 284 ++++++++++----------- src/equicordplugins/randomVoice/styles.css | 4 - 2 files changed, 130 insertions(+), 158 deletions(-) delete mode 100644 src/equicordplugins/randomVoice/styles.css diff --git a/src/equicordplugins/randomVoice/index.tsx b/src/equicordplugins/randomVoice/index.tsx index dd81ba40..74e18099 100644 --- a/src/equicordplugins/randomVoice/index.tsx +++ b/src/equicordplugins/randomVoice/index.tsx @@ -3,18 +3,17 @@ * Copyright (c) 2025 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ -import "./styles.css"; + import { definePluginSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { makeRange } from "@components/PluginSettings/components"; import { debounce } from "@shared/debounce"; import { EquicordDevs } from "@utils/constants"; -import { openUserProfile } from "@utils/discord"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; -import { ChannelStore, RelationshipStore, SelectedChannelStore, ContextMenuApi, GuildStore, Menu, PermissionStore, React, Toasts, UserStore } from "@webpack/common"; +import { ChannelStore, ContextMenuApi, GuildStore, Menu, NavigationRouter, PermissionStore, React, SelectedChannelStore, Toasts, UserStore } from "@webpack/common"; -const ChatVoiceIcon = findComponentByCodeLazy("22H12Zm2-5.26c0") +const ChatVoiceIcon = findComponentByCodeLazy("22H12Zm2-5.26c0"); const Button = findComponentByCodeLazy(".NONE,disabled:", ".PANEL_BUTTON"); const VoiceStateStore = findStoreLazy("VoiceStateStore"); const MediaEngineStore = findStoreLazy("MediaEngineStore"); @@ -144,7 +143,7 @@ export default definePlugin({ { find: "#{intl::ACCOUNT_SPEAKING_WHILE_MUTED}", replacement: { - match: /className:\i\.buttons,.{0,50}children:\[/, + match: /className:\i\.buttons,.{0,60}children:\[/, replace: "$&$self.randomVoice()," } } @@ -152,6 +151,7 @@ export default definePlugin({ settings, randomVoice: ErrorBoundary.wrap(randomVoice, { noop: true }), }); + function randomVoice() { return ( <> @@ -161,8 +161,8 @@ function randomVoice() { role="switch" tooltipText={"Random Voice"} icon={ @@ -174,6 +174,7 @@ function randomVoice() { ); } + function ContextMenu() { let ServerList: any[] = []; Object.values(UserStore.getUsers()).forEach(user => { @@ -202,13 +203,13 @@ function ContextMenu() { const [stream, setStream] = React.useState(settings.store.stream); const [state, setState] = React.useState(settings.store.includeStates); const [notstate, avoidState] = React.useState(settings.store.avoidStates); - + return ( { }} aria-label="Voice state modifier" - > + > { - if (settings.store.Servers.includes(server?.id ?? "invalid server")) + if (settings.store.Servers.includes(server?.id ?? "invalid server")) settings.store.Servers = settings.store.Servers.replace(`/${server.id}`, ""); - else + else settings.store.Servers += `/${server?.id ?? "invalid server"}`; setServers(settings.store.Servers); }} /> ))} - + { const allServerIds = Servers.filter(server => server?.id).map(server => server.id); - settings.store.Servers = `/${allServerIds.join('/')}`; + settings.store.Servers = `/${allServerIds.join("/")}`; setServers(settings.store.Servers); }} disabled={servers.length === Servers.filter(server => server?.id).length} @@ -252,8 +253,6 @@ function ContextMenu() { }} /> - - { }} > - <> - { - setMute(!mute); - settings.store.mute = !mute; - }} - checked={mute} /> - { - setDeafen(!deafen); - settings.store.deafen = !deafen; - }} - checked={deafen} /> - { - setVideo(!video); - settings.store.video = !video; - }} - checked={video} /> - { - setStream(!stream); - settings.store.stream = !stream; - }} - checked={stream} /> - { - setState(!state); - settings.store.includeStates = !state; - }} - checked={state} /> - - { - avoidState(!notstate); - settings.store.avoidStates = !notstate; - }} - checked={notstate} /> - + id="Filter states" + label="Select Filters" + action={() => { }} > + <> + { + setMute(!mute); + settings.store.mute = !mute; + }} + checked={mute} /> + { + setDeafen(!deafen); + settings.store.deafen = !deafen; + }} + checked={deafen} /> + { + setVideo(!video); + settings.store.video = !video; + }} + checked={video} /> + { + setStream(!stream); + settings.store.stream = !stream; + }} + checked={stream} /> + { + setState(!state); + settings.store.includeStates = !state; + }} + checked={state} /> + + { + avoidState(!notstate); + settings.store.avoidStates = !notstate; + }} + checked={notstate} /> + - - - + @@ -412,18 +409,15 @@ function ContextMenu() { - - - - + - + - - ( @@ -439,7 +433,7 @@ function ContextMenu() { renderValue={(value: number) => `${value.toFixed(0)} user${Number(value.toFixed(0)) === 1 ? "" : "s"}`} /> )} /> - { }} > @@ -476,9 +470,6 @@ function ContextMenu() { }} /> - - - @@ -486,7 +477,7 @@ function ContextMenu() { + > - + - { }} > - <> - {} - { - setSelfMute(!muteself); - settings.store.selfMute = !muteself; - }} - checked={muteself} /> - { - setSelfDeafen(!deafenself); - settings.store.selfDeafen = !deafenself; - }} - checked={deafenself} /> - { - setCamera(!camera); - settings.store.autoCamera = !camera; - }} - checked={camera} /> + > + { }} > + <> + { } + { + setSelfMute(!muteself); + settings.store.selfMute = !muteself; + }} + checked={muteself} /> + { + setSelfDeafen(!deafenself); + settings.store.selfDeafen = !deafenself; + }} + checked={deafenself} /> + { + setCamera(!camera); + settings.store.autoCamera = !camera; + }} + checked={camera} /> @@ -591,10 +582,7 @@ function ContextMenu() { }} checked={navigate} /> - - - - - + ); } + function getChannels() { const criteriaChannel: any[] = []; @@ -630,9 +619,9 @@ function getChannels() { const channel = ChannelStore.getChannel(channelId); if (!channel) return; const channelVoiceStates = VoiceStateStore.getVoiceStatesForChannel(channelId); - + if (!settings.store.Servers.split("/").includes(channel.getGuildId())) return; - if (settings.store.avoidStages && channel.isGuildStageVoice()) return; + if (settings.store.avoidStages && channel.isGuildStageVoice()) return; const operations = { ">": (a, b) => a < b, "<": (a, b) => a > b, @@ -656,31 +645,31 @@ function getChannels() { const channelVoiceStates = VoiceStateStore.getVoiceStatesForChannel(channel.id); let mismatchedStates = 0; let bestChannelId: string | null = null; - for (const state of Object.values(channelVoiceStates) as { selfMute?: boolean; selfDeaf?: boolean; selfVideo?: boolean; selfStream?: boolean }[]) { + for (const state of Object.values(channelVoiceStates) as { selfMute?: boolean; selfDeaf?: boolean; selfVideo?: boolean; selfStream?: boolean; }[]) { if ((settings.store.deafen && state.selfDeaf) || (!settings.store.deafen && !state.selfDeaf)) mismatchedStates++; if ((settings.store.video && !state.selfVideo) || (!settings.store.video && state.selfVideo)) mismatchedStates++; if ((settings.store.stream && !state.selfStream) || (!settings.store.stream && state.selfStream)) mismatchedStates++; + if (!settings.store.deafen) { if ((settings.store.mute && state.selfMute) || (!settings.store.mute && !state.selfMute)) mismatchedStates++; } } - + if (mismatchedStates < lowestMismatchCount) { - lowestMismatchCount = mismatchedStates; - bestChannelId = channel.id + lowestMismatchCount = mismatchedStates; + bestChannelId = channel.id; } if (bestChannelId) { criteriaChannel.push(channelId); } } - - - - + + if (settings.store.includeStates && !settings.store.avoidStates) { if ((settings.store.deafen && !selfDeaf) || (!settings.store.deafen && selfDeaf)) return; if ((settings.store.video && !selfVideo) || (!settings.store.video && selfVideo)) return; if ((settings.store.stream && !selfStream) || (!settings.store.stream && selfStream)) return; + if (!settings.store.deafen) if ((settings.store.mute && !selfMute) || (!settings.store.mute && selfMute)) return; @@ -703,32 +692,19 @@ function getChannels() { const randomIndex = Math.floor(Math.random() * criteriaChannel.length); JoinVc(criteriaChannel[randomIndex]); - } + function JoinVc(channelID) { const channel = ChannelStore.getChannel(channelID); ChannelActions.selectVoiceChannel(channelID); - if (settings.store.autoNavigate) autoNavigate(channel.guild_id, channel.id); - + if (settings.store.autoNavigate) NavigationRouter.transitionTo(channel.guild_id, channel.id); if (settings.store.autoCamera && PermissionStore.can(STREAM, channel)) autoCamera(); - if (settings.store.autoCamera && PermissionStore.can(STREAM, channel)) autoCamera(); - if (settings.store.selfMute && !MediaEngineStore.isSelfMute() && SelectedChannelStore.getVoiceChannelId()) toggleSelfMute(); - if (settings.store.selfDeafen && !MediaEngineStore.isSelfDeaf() && SelectedChannelStore.getVoiceChannelId()) toggleSelfDeaf(); } -function autoNavigate(guild: string, channel: string) { - const checkExist = setInterval(() => { - const navigate = document.querySelector(`a[href="/channels/${guild}/${channel}"]`) as HTMLButtonElement; - if (navigate) { - navigate.click(); - clearInterval(checkExist); - } - }, 50); -} function autoCamera() { const checkExist = setInterval(() => { diff --git a/src/equicordplugins/randomVoice/styles.css b/src/equicordplugins/randomVoice/styles.css deleted file mode 100644 index f07df7e0..00000000 --- a/src/equicordplugins/randomVoice/styles.css +++ /dev/null @@ -1,4 +0,0 @@ -.buttons__37e49 { - width: 5px; - margin-left: -13px; - } \ No newline at end of file