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