mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
add agent support (#1973)
This commit is contained in:
@@ -60,6 +60,7 @@
|
||||
"node": ">=8.0.0"
|
||||
},
|
||||
"browser": {
|
||||
"https": false,
|
||||
"ws": false,
|
||||
"uws": false,
|
||||
"erlpack": false,
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
const querystring = require('querystring');
|
||||
const snekfetch = require('snekfetch');
|
||||
const https = require('https');
|
||||
|
||||
if (https.Agent) var agent = new https.Agent({ keepAlive: true });
|
||||
|
||||
class APIRequest {
|
||||
constructor(rest, method, path, options) {
|
||||
@@ -20,7 +23,7 @@ class APIRequest {
|
||||
this.path += `?${queryString}`;
|
||||
}
|
||||
|
||||
const request = snekfetch[this.method](`${API}${this.path}`);
|
||||
const request = snekfetch[this.method](`${API}${this.path}`, { agent });
|
||||
|
||||
if (this.options.auth !== false) request.set('Authorization', this.rest.getAuth());
|
||||
if (this.options.reason) request.set('X-Audit-Log-Reason', encodeURIComponent(this.options.reason));
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript" src="../webpack/discord.12.0.0-dev.min.js"></script>
|
||||
<script type="text/javascript" src="../webpack/discord.12.0.0-dev.js"></script>
|
||||
<script type="text/javascript" src="auth.js"></script>
|
||||
<script type="text/javascript">
|
||||
(() => {
|
||||
@@ -15,6 +15,8 @@
|
||||
console.log('[CLIENT] Ready!');
|
||||
});
|
||||
|
||||
client.on('debug', console.log);
|
||||
|
||||
client.on('error', console.error);
|
||||
|
||||
client.ws.on('close', (event) => console.log('[CLIENT] Disconnect!', event));
|
||||
|
||||
Reference in New Issue
Block a user