@discordjs/rest
Advanced tools
Comparing version 0.5.0-dev.1652702640-5e9b757 to 0.5.0-dev.1652832624-dfe449c
@@ -8,2 +8,2 @@ export * from './lib/CDN'; | ||
export * from './lib/utils/constants'; | ||
export { makeURLSearchParams } from './lib/utils/utils'; | ||
export { makeURLSearchParams, parseResponse } from './lib/utils/utils'; |
@@ -159,3 +159,4 @@ "use strict"; | ||
RequestMethod: () => RequestMethod, | ||
makeURLSearchParams: () => makeURLSearchParams | ||
makeURLSearchParams: () => makeURLSearchParams, | ||
parseResponse: () => parseResponse | ||
}); | ||
@@ -686,3 +687,3 @@ module.exports = __toCommonJS(src_exports); | ||
if (status >= 200 && status < 300) { | ||
return parseResponse(res); | ||
return res; | ||
} else if (status === 429) { | ||
@@ -753,3 +754,3 @@ const isGlobal = this.globalLimited; | ||
} | ||
return null; | ||
return res; | ||
} | ||
@@ -997,3 +998,7 @@ } | ||
} | ||
request(options) { | ||
async request(options) { | ||
const response = await this.raw(options); | ||
return parseResponse(response); | ||
} | ||
raw(options) { | ||
return this.requestManager.queueRequest(options); | ||
@@ -1018,4 +1023,5 @@ } | ||
RequestMethod, | ||
makeURLSearchParams | ||
makeURLSearchParams, | ||
parseResponse | ||
}); | ||
//# sourceMappingURL=index.js.map |
@@ -0,7 +1,8 @@ | ||
import type { Dispatcher } from 'undici'; | ||
import type { RequestOptions } from '../REST'; | ||
import type { HandlerRequestData, RouteData } from '../RequestManager'; | ||
export interface IHandler { | ||
queueRequest: (routeId: RouteData, url: string, options: RequestOptions, requestData: HandlerRequestData) => Promise<unknown>; | ||
queueRequest: (routeId: RouteData, url: string, options: RequestOptions, requestData: HandlerRequestData) => Promise<Dispatcher.ResponseData>; | ||
get inactive(): boolean; | ||
readonly id: string; | ||
} |
@@ -0,1 +1,2 @@ | ||
import { type Dispatcher } from 'undici'; | ||
import type { IHandler } from './IHandler'; | ||
@@ -73,3 +74,3 @@ import type { RequestOptions } from '../REST'; | ||
*/ | ||
queueRequest(routeId: RouteData, url: string, options: RequestOptions, requestData: HandlerRequestData): Promise<unknown>; | ||
queueRequest(routeId: RouteData, url: string, options: RequestOptions, requestData: HandlerRequestData): Promise<Dispatcher.ResponseData>; | ||
/** | ||
@@ -76,0 +77,0 @@ * The method that actually makes the request to the api, and updates info about the bucket accordingly |
@@ -185,3 +185,3 @@ /// <reference types="node" /> | ||
*/ | ||
queueRequest(request: InternalRequest): Promise<unknown>; | ||
queueRequest(request: InternalRequest): Promise<Dispatcher.ResponseData>; | ||
/** | ||
@@ -188,0 +188,0 @@ * Creates a new rate limit handler from a hash, based on the hash and the major parameter |
@@ -250,2 +250,7 @@ /// <reference types="node" /> | ||
request(options: InternalRequest): Promise<unknown>; | ||
/** | ||
* Runs a request from the API, yielding the raw Response object | ||
* @param options Request options | ||
*/ | ||
raw(options: InternalRequest): Promise<Dispatcher.ResponseData>; | ||
} |
{ | ||
"name": "@discordjs/rest", | ||
"version": "0.5.0-dev.1652702640-5e9b757", | ||
"version": "0.5.0-dev.1652832624-dfe449c", | ||
"description": "The REST API for discord.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
303306
2850