mirror of
https://github.com/danbulant/discord.js
synced 2026-05-27 22:11:53 +00:00
Fix query string on requests after ratelimited (#2215)
* Fix querystring being appended multiple times when ratelimited * Better way? * Better better way * Fix empty queries
This commit is contained in:
parent
45127bb408
commit
01f1f1b58e
1 changed files with 3 additions and 6 deletions
|
|
@ -10,20 +10,17 @@ class APIRequest {
|
|||
this.rest = rest;
|
||||
this.client = rest.client;
|
||||
this.method = method;
|
||||
this.path = path.toString();
|
||||
this.route = options.route;
|
||||
this.options = options;
|
||||
|
||||
const queryString = (querystring.stringify(options.query).match(/[^=&?]+=[^=&?]+/g) || []).join('&');
|
||||
this.path = `${path}${queryString ? `?${queryString}` : ''}`;
|
||||
}
|
||||
|
||||
gen() {
|
||||
const API = this.options.versioned === false ? this.client.options.http.api :
|
||||
`${this.client.options.http.api}/v${this.client.options.http.version}`;
|
||||
|
||||
if (this.options.query) {
|
||||
const queryString = (querystring.stringify(this.options.query).match(/[^=&?]+=[^=&?]+/g) || []).join('&');
|
||||
this.path += `?${queryString}`;
|
||||
}
|
||||
|
||||
const request = snekfetch[this.method](`${API}${this.path}`, { agent });
|
||||
|
||||
if (this.options.auth !== false) request.set('Authorization', this.rest.getAuth());
|
||||
|
|
|
|||
Loading…
Reference in a new issue