From 8b459434031e2628830b903bc8884ebd84f85360 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sun, 1 Feb 2026 01:53:00 -0500 Subject: [PATCH] VoiceRejoin: RejoinTimeout & Fix Old Rejoins + Other Devices --- src/equicordplugins/voiceRejoin/index.tsx | 26 ++++++++++++++++++++--- src/plugins/experiments/index.tsx | 4 ++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/equicordplugins/voiceRejoin/index.tsx b/src/equicordplugins/voiceRejoin/index.tsx index ddd673a62..154508722 100644 --- a/src/equicordplugins/voiceRejoin/index.tsx +++ b/src/equicordplugins/voiceRejoin/index.tsx @@ -21,6 +21,13 @@ const settings = definePluginSettings({ default: 2, stickToMarkers: true, }, + rejoinTimeout: { + type: OptionType.SLIDER, + description: "Don't attempt to rejoin after this many seconds have passed since disconnecting.", + markers: makeRange(5, 120, 5), + default: 30, + stickToMarkers: true, + }, preventReconnectIfCallEnded: { type: OptionType.SELECT, description: "Do not reconnect if the call has ended or the voice channel is empty or does not exist.", @@ -41,9 +48,7 @@ export default definePlugin({ flux: { VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: any[]; }) { - const myUserId = UserStore?.getCurrentUser?.()?.id; - if (!myUserId) return; - + const myUserId = UserStore.getCurrentUser().id; const myState = voiceStates.find(s => s.userId === myUserId); if (!myState) return; @@ -51,6 +56,7 @@ export default definePlugin({ const saved = { guildId: myState.guildId ?? null, channelId: myState.channelId, + timestamp: Date.now(), }; DataStore.set(DATASTORE_KEY, saved); DataStore.set(DATASTORE_SESSION_KEY, true); @@ -70,6 +76,12 @@ export default definePlugin({ const saved = await DataStore.get(DATASTORE_KEY); if (!saved?.channelId) return; + const timeoutMs = settings.store.rejoinTimeout * 1000; + if (saved.timestamp && Date.now() - saved.timestamp > timeoutMs) { + DataStore.set(DATASTORE_SESSION_KEY, false); + return; + } + const preventionMode = settings.store.preventReconnectIfCallEnded; if (preventionMode !== "none") { const channel = ChannelStore.getChannel(saved.channelId); @@ -98,6 +110,14 @@ export default definePlugin({ } } + const myUserId = UserStore.getCurrentUser().id; + const myVoiceState = VoiceStateStore.getVoiceStateForUser(myUserId); + + if (myVoiceState?.channelId) { + DataStore.set(DATASTORE_SESSION_KEY, false); + return; + } + FluxDispatcher.dispatch({ type: "VOICE_CHANNEL_SELECT", guildId: saved.guildId, diff --git a/src/plugins/experiments/index.tsx b/src/plugins/experiments/index.tsx index e4e5712e4..47f9e3dad 100644 --- a/src/plugins/experiments/index.tsx +++ b/src/plugins/experiments/index.tsx @@ -123,8 +123,8 @@ export default definePlugin({ { find: "{PlaygroundEmbed:()=>", replacement: { - match: /getCurrentUser\(\);return\(null==\i\?void 0:\i\.isStaff\(\)\)/, - replace: "getCurrentUser();return(true" + match: /PotionIcon.{0,250}getCurrentUser\(\);return/, + replace: "$& true||" } } ],