From 5f0debdfb23985476e6d113612bf1ea156ea489c Mon Sep 17 00:00:00 2001 From: ludd50155 Date: Fri, 6 Feb 2026 22:10:50 +0800 Subject: [PATCH] Fix: check cleanups --- src/discord/monitor/provider.ts | 43 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/discord/monitor/provider.ts b/src/discord/monitor/provider.ts index 4f791faa08..2845219767 100644 --- a/src/discord/monitor/provider.ts +++ b/src/discord/monitor/provider.ts @@ -72,33 +72,32 @@ function createDiscordGatewayPlugin(params: { return new GatewayPlugin(options); } - let agent: HttpsProxyAgent | undefined; try { - agent = new HttpsProxyAgent(proxy); + const agent = new HttpsProxyAgent(proxy); + + params.runtime.log?.("discord: gateway proxy enabled"); + + class ProxyGatewayPlugin extends GatewayPlugin { + #proxyAgent: HttpsProxyAgent; + + constructor(proxyAgent: HttpsProxyAgent) { + super(options); + this.#proxyAgent = proxyAgent; + } + + createWebSocket(url?: string) { + if (!url) { + throw new Error("Gateway URL is required"); + } + return new WebSocket(url, { agent: this.#proxyAgent }); + } + } + + return new ProxyGatewayPlugin(agent); } catch (err) { params.runtime.error?.(danger(`discord: invalid gateway proxy: ${String(err)}`)); return new GatewayPlugin(options); } - - params.runtime.log?.("discord: gateway proxy enabled"); - - class ProxyGatewayPlugin extends GatewayPlugin { - #proxyAgent: HttpsProxyAgent; - - constructor(proxyAgent: HttpsProxyAgent) { - super(options); - this.#proxyAgent = proxyAgent; - } - - createWebSocket(url?: string) { - if (!url) { - throw new Error("Gateway URL is required"); - } - return new WebSocket(url, { agent: this.#proxyAgent }); - } - } - - return new ProxyGatewayPlugin(agent); } function summarizeAllowList(list?: Array) {