diff --git a/src/rest/APIRouter.js b/src/rest/APIRouter.js index 715b1c7c4..4d1fb5d6b 100644 --- a/src/rest/APIRouter.js +++ b/src/rest/APIRouter.js @@ -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);