mirror of
https://github.com/danbulant/discord.js
synced 2026-06-19 22:51:32 +00:00
add agent support (#1973)
This commit is contained in:
parent
97dc85f491
commit
4d4d2f2db7
3 changed files with 8 additions and 2 deletions
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Reference in a new issue