mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix(rate-limits): reactions buckets need to be shared with sub-… (#3439)
This commit is contained in:
@@ -13,13 +13,18 @@ function buildRoute(manager) {
|
||||
get(target, name) {
|
||||
if (reflectors.includes(name)) return () => route.join('/');
|
||||
if (methods.includes(name)) {
|
||||
const routeBucket = [];
|
||||
for (let i = 0; i < route.length; i++) {
|
||||
// Reactions routes and sub-routes all share the same bucket
|
||||
if (route[i - 1] === 'reactions') break;
|
||||
// Literal IDs should only be taken account if they are the Major ID (the Channel/Guild ID)
|
||||
if (/\d{16,19}/g.test(route[i]) && !/channels|guilds/.test(route[i - 1])) routeBucket.push(':id');
|
||||
// All other parts of the route should be considered as part of the bucket identifier
|
||||
else routeBucket.push(route[i]);
|
||||
}
|
||||
return options => manager.request(name, route.join('/'), Object.assign({
|
||||
versioned: manager.versioned,
|
||||
route: route.map((r, i) => {
|
||||
if (/\d{16,19}/g.test(r)) return /channels|guilds/.test(route[i - 1]) ? r : ':id';
|
||||
if (route[i - 1] === 'reactions') return ':reaction';
|
||||
return r;
|
||||
}).join('/'),
|
||||
route: routeBucket.join('/'),
|
||||
}, options));
|
||||
}
|
||||
route.push(name);
|
||||
|
||||
Reference in New Issue
Block a user