mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +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:
@@ -304,11 +304,16 @@ export class SequentialHandler implements IHandler {
|
||||
// Let library users know when rate limit buckets have been updated
|
||||
this.debug(['Received bucket hash update', ` Old Hash : ${this.hash}`, ` New Hash : ${hash}`].join('\n'));
|
||||
// This queue will eventually be eliminated via attrition
|
||||
this.manager.hashes.set(`${method}:${routeId.bucketRoute}`, { value: hash, lastAccess: Date.now() });
|
||||
this.manager.hashes.set(
|
||||
`${method}:${routeId.bucketRoute}${typeof requestData.auth === 'string' ? `:${requestData.auth}` : ''}`,
|
||||
{ value: hash, lastAccess: Date.now() },
|
||||
);
|
||||
} else if (hash) {
|
||||
// Handle the case where hash value doesn't change
|
||||
// Fetch the hash data from the manager
|
||||
const hashData = this.manager.hashes.get(`${method}:${routeId.bucketRoute}`);
|
||||
const hashData = this.manager.hashes.get(
|
||||
`${method}:${routeId.bucketRoute}${typeof requestData.auth === 'string' ? `:${requestData.auth}` : ''}`,
|
||||
);
|
||||
|
||||
// When fetched, update the last access of the hash
|
||||
if (hashData) {
|
||||
|
||||
@@ -138,7 +138,7 @@ export async function handleErrors(
|
||||
// Handle possible malformed requests
|
||||
if (status >= 400 && status < 500) {
|
||||
// If we receive this status code, it means the token we had is no longer valid.
|
||||
if (status === 401 && requestData.auth) {
|
||||
if (status === 401 && requestData.auth === true) {
|
||||
manager.setToken(null!);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user