feat: REST#raw (#7929)

This commit is contained in:
DD
2022-05-17 17:31:19 +03:00
committed by GitHub
parent 5e9b757a37
commit dfe449c253
5 changed files with 19 additions and 8 deletions

View File

@@ -13,6 +13,7 @@ import {
import type { HashData } from './RequestManager';
import type { IHandler } from './handlers/IHandler';
import { DefaultRestOptions, RESTEvents } from './utils/constants';
import { parseResponse } from './utils/utils';
/**
* Options to be passed when creating the REST instance
@@ -314,7 +315,16 @@ export class REST extends EventEmitter {
* Runs a request from the api
* @param options Request options
*/
public request(options: InternalRequest) {
public async request(options: InternalRequest) {
const response = await this.raw(options);
return parseResponse(response);
}
/**
* Runs a request from the API, yielding the raw Response object
* @param options Request options
*/
public raw(options: InternalRequest) {
return this.requestManager.queueRequest(options);
}
}