import { REST, ResponseLike, DiscordAPIError, HTTPError, RateLimitError } from '@discordjs/rest'; import { IncomingMessage, ServerResponse } from 'node:http'; import { Awaitable } from '@discordjs/util'; /** * Represents a simple HTTP request handler */ type RequestHandler = (req: IncomingMessage, res: ServerResponse) => Awaitable; /** * Creates an HTTP handler used to forward requests to Discord * * @param rest - REST instance to use for the requests */ declare function proxyRequests(rest: REST): RequestHandler; /** * Populates a server response with the data from a Discord 2xx REST response * * @param res - The server response to populate * @param data - The data to populate the response with */ declare function populateSuccessfulResponse(res: ServerResponse, data: ResponseLike): Promise; /** * Populates a server response with the data from a Discord non-2xx REST response that is NOT a 429 * * @param res - The server response to populate * @param error - The error to populate the response with */ declare function populateGeneralErrorResponse(res: ServerResponse, error: DiscordAPIError | HTTPError): void; /** * Populates a server response with the data from a Discord 429 REST response * * @param res - The server response to populate * @param error - The error to populate the response with */ declare function populateRatelimitErrorResponse(res: ServerResponse, error: RateLimitError): void; /** * Populates a server response with data relevant for a timeout * * @param res - The sever response to populate */ declare function populateAbortErrorResponse(res: ServerResponse): void; /** * Tries to populate a server response from an error object * * @param res - The server response to populate * @param error - The error to check and use * @returns `true` if the error is known and the response object was populated, otherwise `false` */ declare function populateErrorResponse(res: ServerResponse, error: unknown): boolean; /** * The {@link https://github.com/discordjs/discord.js/blob/main/packages/proxy#readme | @discordjs/proxy} version * that you are currently using. * * @privateRemarks This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild. */ declare const version: string; export { type RequestHandler, populateAbortErrorResponse, populateErrorResponse, populateGeneralErrorResponse, populateRatelimitErrorResponse, populateSuccessfulResponse, proxyRequests, version };