Fix: check cleanups

This commit is contained in:
ludd50155
2026-02-06 22:10:50 +08:00
committed by Shadow
parent 0cb69b0f28
commit 5f0debdfb2
+7 -8
View File
@@ -72,20 +72,15 @@ function createDiscordGatewayPlugin(params: {
return new GatewayPlugin(options); return new GatewayPlugin(options);
} }
let agent: HttpsProxyAgent | undefined;
try { try {
agent = new HttpsProxyAgent(proxy); const agent = new HttpsProxyAgent<string>(proxy);
} catch (err) {
params.runtime.error?.(danger(`discord: invalid gateway proxy: ${String(err)}`));
return new GatewayPlugin(options);
}
params.runtime.log?.("discord: gateway proxy enabled"); params.runtime.log?.("discord: gateway proxy enabled");
class ProxyGatewayPlugin extends GatewayPlugin { class ProxyGatewayPlugin extends GatewayPlugin {
#proxyAgent: HttpsProxyAgent; #proxyAgent: HttpsProxyAgent<string>;
constructor(proxyAgent: HttpsProxyAgent) { constructor(proxyAgent: HttpsProxyAgent<string>) {
super(options); super(options);
this.#proxyAgent = proxyAgent; this.#proxyAgent = proxyAgent;
} }
@@ -99,6 +94,10 @@ function createDiscordGatewayPlugin(params: {
} }
return new ProxyGatewayPlugin(agent); return new ProxyGatewayPlugin(agent);
} catch (err) {
params.runtime.error?.(danger(`discord: invalid gateway proxy: ${String(err)}`));
return new GatewayPlugin(options);
}
} }
function summarizeAllowList(list?: Array<string | number>) { function summarizeAllowList(list?: Array<string | number>) {