mirror of
https://github.com/danbulant/discord.js
synced 2026-05-25 04:52:22 +00: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:
parent
b68283e57a
commit
4a7284b86e
1 changed files with 11 additions and 11 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue