mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01: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:
@@ -10,20 +10,17 @@ class APIRequest {
|
|||||||
this.rest = rest;
|
this.rest = rest;
|
||||||
this.client = rest.client;
|
this.client = rest.client;
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.path = path.toString();
|
|
||||||
this.route = options.route;
|
this.route = options.route;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
|
const queryString = (querystring.stringify(options.query).match(/[^=&?]+=[^=&?]+/g) || []).join('&');
|
||||||
|
this.path = `${path}${queryString ? `?${queryString}` : ''}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
gen() {
|
gen() {
|
||||||
const API = this.options.versioned === false ? this.client.options.http.api :
|
const API = this.options.versioned === false ? this.client.options.http.api :
|
||||||
`${this.client.options.http.api}/v${this.client.options.http.version}`;
|
`${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 });
|
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());
|
||||||
|
|||||||
Reference in New Issue
Block a user