fix(voice): prevent 24/7 rejoin spam when bot is not in guild or voice times out

- Check guild membership before BootRecovery and Watchdog sweeps; keep settings intact if bot is not in server
- Wire up RejoinBackoff to apply exponential cooldown when voice joins time out
- Stop redundant retry loops and deduplicate join failure logs
This commit is contained in:
NoLogicAlan committed 2026-10-21 03:38:12 +03:00
1 parent 355f6b1129
commit f2bfff59b5
5 files changed
+61 -8

No files matched your search

+17 -2
View File
@@ -19,6 +19,7 @@ import VoiceStateRouting from "./VoiceStateRouting.mjs";
import GuildSync from "./GuildSync.mjs";
import RejoinManager from "./RejoinManager.mjs";
import Watchdog247 from "./Watchdog247.mjs";
import RejoinBackoff from "./RejoinBackoff.mjs";
const RAW_GATEWAY_INTEREST =
/"(?:t|op)":\s*(?:"(?:VOICE_STATE_UPDATE|VOICE_SERVER_UPDATE|GUILD_CREATE|READY|RESUMED)"|(?:7|9|10|12)\b)/;
@@ -41,6 +42,8 @@ class GatewayHandler {
this.presenceContents = remix.config.presenceContents ?? [];
this.presenceInterval = remix.config.presenceInterval ?? 30_000;
this.rejoinBackoff = new RejoinBackoff();
this.wsListenerAttached = false;
this.presenceTimer = null;
this.presenceIndex = 0;
@@ -521,6 +524,16 @@ class GatewayHandler {
for (let i = 0; i < channelsToRejoin.length; i++) {
const { guildId, channelId, mode } = channelsToRejoin[i];
const cleanG = cleanId(guildId);
const cleanC = cleanId(channelId);
const guild = remix.client?.guilds?.get?.(cleanG);
if (!guild) {
logger.voice247(
`[BootRecovery] Bot is not currently in guild ${cleanG} — skipping channel ${cleanC} (setting kept intact).`
);
continue;
}
if (i > 0) {
let staggerDelay = baseStagger;
@@ -581,13 +594,15 @@ class GatewayHandler {
const player = await this._attemptRejoin(channelId, guildId, 3, 5_000, "BootRecovery");
if (player) {
this.rejoinBackoff?.recordSuccess?.(channelId);
logger.voice247(
`[BootRecovery] Successfully rejoined channel ${channelId} (mode: ${mode}) [${i + 1}/${channelsToRejoin.length}]`
);
} else {
this.rejoinBackoff?.recordFailure?.(channelId);
logger.warn(
`[BootRecovery] Failed to rejoin channel ${channelId} in guild ${guildId} after retries — ` +
`keeping 24/7 setting intact, will retry on next disconnect/restart.`
`[BootRecovery] Could not rejoin channel ${channelId} in guild ${guildId} — ` +
`keeping 24/7 setting intact (backed off).`
);
}
}