mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
move function getRoute(url) into class APIRequest (#1065)
this.route = getRoute(this.url); >>> this.route = this.getRoute(this.url);
This commit is contained in:
@@ -1,16 +1,6 @@
|
||||
const request = require('superagent');
|
||||
const Constants = require('../../util/Constants');
|
||||
|
||||
function getRoute(url) {
|
||||
let route = url.split('?')[0];
|
||||
if (route.includes('/channels/') || route.includes('/guilds/')) {
|
||||
const startInd = route.includes('/channels/') ? route.indexOf('/channels/') : route.indexOf('/guilds/');
|
||||
const majorID = route.substring(startInd).split('/')[2];
|
||||
route = route.replace(/(\d{8,})/g, ':id').replace(':id', majorID);
|
||||
}
|
||||
return route;
|
||||
}
|
||||
|
||||
class APIRequest {
|
||||
constructor(rest, method, url, auth, data, file) {
|
||||
this.rest = rest;
|
||||
@@ -19,7 +9,17 @@ class APIRequest {
|
||||
this.auth = auth;
|
||||
this.data = data;
|
||||
this.file = file;
|
||||
this.route = getRoute(this.url);
|
||||
this.route = this.getRoute(this.url);
|
||||
}
|
||||
|
||||
getRoute(url) {
|
||||
let route = url.split('?')[0];
|
||||
if (route.includes('/channels/') || route.includes('/guilds/')) {
|
||||
const startInd = route.includes('/channels/') ? route.indexOf('/channels/') : route.indexOf('/guilds/');
|
||||
const majorID = route.substring(startInd).split('/')[2];
|
||||
route = route.replace(/(\d{8,})/g, ':id').replace(':id', majorID);
|
||||
}
|
||||
return route;
|
||||
}
|
||||
|
||||
getAuth() {
|
||||
|
||||
Reference in New Issue
Block a user