mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix(APIRequest): group reaction requests into one route per channel (#4017)
* fix(APIRequest): group all reactions into the same route per channel * refactor(APIRequest): make route a const
This commit is contained in:
@@ -15,13 +15,17 @@ class APIRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getRoute(url) {
|
getRoute(url) {
|
||||||
let route = url.split('?')[0];
|
const route = url.split('?')[0].split('/');
|
||||||
if (route.includes('/channels/') || route.includes('/guilds/')) {
|
const routeBucket = [];
|
||||||
const startInd = route.includes('/channels/') ? route.indexOf('/channels/') : route.indexOf('/guilds/');
|
for (let i = 0; i < route.length; i++) {
|
||||||
const majorID = route.substring(startInd).split('/')[2];
|
// Reactions routes and sub-routes all share the same bucket
|
||||||
route = route.replace(/(\d{8,})/g, ':id').replace(':id', majorID);
|
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 route;
|
return routeBucket.join('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
getAuth() {
|
getAuth() {
|
||||||
|
|||||||
Reference in New Issue
Block a user