mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 18:13:29 +01:00
feat(rest)!: allow passing tokens per request (#10682)
BREAKING CHANGE: `RequestData.authPrefix` has been removed in favor of `RequestData.auth.prefix`
This commit is contained in:
@@ -60,3 +60,5 @@ export const OverwrittenMimeTypes = {
|
||||
} as const satisfies Readonly<Record<string, string>>;
|
||||
|
||||
export const BurstHandlerMajorIdKey = 'burst';
|
||||
|
||||
export const AUTH_UUID_NAMESPACE = 'acc82a4c-f887-417b-a69c-f74096ff7e59';
|
||||
|
||||
@@ -269,6 +269,19 @@ export interface RawFile {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface AuthData {
|
||||
/**
|
||||
* The authorization prefix to use for this request, useful if you use this with bearer tokens
|
||||
*
|
||||
* @defaultValue `REST.options.authPrefix`
|
||||
*/
|
||||
prefix?: 'Bearer' | 'Bot';
|
||||
/**
|
||||
* The authorization token to use for this request
|
||||
*/
|
||||
token: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents possible data to be given to an endpoint
|
||||
*/
|
||||
@@ -278,17 +291,11 @@ export interface RequestData {
|
||||
*/
|
||||
appendToFormData?: boolean;
|
||||
/**
|
||||
* If this request needs the `Authorization` header
|
||||
* Alternate authorization data to use for this request only, or `false` to disable the Authorization header
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
auth?: boolean;
|
||||
/**
|
||||
* The authorization prefix to use for this request, useful if you use this with bearer tokens
|
||||
*
|
||||
* @defaultValue `'Bot'`
|
||||
*/
|
||||
authPrefix?: 'Bearer' | 'Bot';
|
||||
auth?: AuthData | boolean;
|
||||
/**
|
||||
* The body to send to this request.
|
||||
* If providing as BodyInit, set `passThroughBody: true`
|
||||
@@ -363,7 +370,9 @@ export interface InternalRequest extends RequestData {
|
||||
method: RequestMethod;
|
||||
}
|
||||
|
||||
export type HandlerRequestData = Pick<InternalRequest, 'auth' | 'body' | 'files' | 'signal'>;
|
||||
export interface HandlerRequestData extends Pick<InternalRequest, 'body' | 'files' | 'signal'> {
|
||||
auth: boolean | string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parsed route data for an endpoint
|
||||
|
||||
Reference in New Issue
Block a user