Fixed Proxy
This commit is contained in:
@@ -40,7 +40,7 @@ const Options = require('../util/Options');
|
||||
const Permissions = require('../util/Permissions');
|
||||
const DiscordAuthWebsocket = require('../util/RemoteAuth');
|
||||
const Sweepers = require('../util/Sweepers');
|
||||
const { testImportModule } = require('../util/Util');
|
||||
const { getProxyObject } = require('../util/Util');
|
||||
|
||||
/**
|
||||
* The main hub for interacting with the Discord API, and the starting point for any bot.
|
||||
@@ -1021,10 +1021,9 @@ class Client extends BaseClient {
|
||||
} else if (
|
||||
options &&
|
||||
options.proxy &&
|
||||
typeof options.proxy === 'string' &&
|
||||
testImportModule('proxy-agent') === false
|
||||
typeof options.proxy === 'string'
|
||||
) {
|
||||
throw new Error('MISSING_MODULE', 'proxy-agent', 'npm install proxy-agent@5');
|
||||
getProxyObject(options.proxy);
|
||||
}
|
||||
if (typeof options.shardCount !== 'number' || isNaN(options.shardCount) || options.shardCount < 1) {
|
||||
throw new TypeError('CLIENT_INVALID_OPTION', 'shardCount', 'a number greater than or equal to 1');
|
||||
|
@@ -5,6 +5,7 @@ const { setTimeout, setInterval, clearTimeout } = require('node:timers');
|
||||
const WebSocket = require('../../WebSocket');
|
||||
const { Status, Events, ShardEvents, Opcodes, WSEvents, WSCodes } = require('../../util/Constants');
|
||||
const Intents = require('../../util/Intents');
|
||||
const { getProxyObject } = require('../../util/Util');
|
||||
|
||||
const STATUS_KEYS = Object.keys(Status);
|
||||
const CONNECTION_STATE = Object.keys(WebSocket.WebSocket);
|
||||
@@ -280,8 +281,7 @@ class WebSocketShard extends EventEmitter {
|
||||
|
||||
let args = { handshakeTimeout: 30_000 };
|
||||
if (client.options.proxy.length > 0) {
|
||||
const ProxyAgent = require('proxy-agent');
|
||||
args.agent = new ProxyAgent(client.options.proxy);
|
||||
args.agent = getProxyObject(client.options.proxy);
|
||||
this.debug(`Using proxy ${client.options.proxy}`, args);
|
||||
}
|
||||
// Adding a handshake timeout to just make sure no zombie connection appears.
|
||||
|
Reference in New Issue
Block a user