fix(discord): replace a gateway that gave up when the same config is saved again

This commit is contained in:
Devvyn committed 2026-10-30 14:27:36 +08:00
1 parent d044e49635
commit 9f18b78857
2 files changed
+26 -1

No files matched your search

+2 -1
View File
@@ -769,8 +769,9 @@ export class DiscordBridge {
}
activeStartupHint = this.cfg.enabled && this.cfg.token && this.cfg.startupHint ? DISCORD_STARTUP_HINT : undefined;
// A save that changed neither the switch nor the token keeps the gateway session, so it can resume.
// A gateway that gave up (a fatal close, such as a missing intent) is replaced, or a fix could never take.
const want = this.cfg.enabled && this.cfg.token && !this.held ? this.cfg.token : '';
if (this.gateway && want && want === this.gatewayToken) return;
if (this.gateway && this.gateway.state !== 'error' && want && want === this.gatewayToken) return;
this.gateway?.stop();
this.gateway = null;
this.gatewayToken = want;