cleanup ws ratelimiting, and apirequest (#957)

* cleanup ws ratelimiting, and apirequest

* cleanup timestamps

* clean up timestamps
This commit is contained in:
Gus Caplan
2016-12-23 08:37:43 -06:00
committed by Amish Shah
parent 74ef0b2e14
commit e6a041241b
3 changed files with 16 additions and 18 deletions

View File

@@ -4,7 +4,7 @@ const Constants = require('../../util/Constants');
function getRoute(url) {
let route = url.split('?')[0];
if (route.includes('/channels/') || route.includes('/guilds/')) {
const startInd = ~route.indexOf('/channels/') ? route.indexOf('/channels/') : route.indexOf('/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);
}
@@ -37,11 +37,7 @@ class APIRequest {
if (this.file && this.file.file) {
apiRequest.attach('file', this.file.file, this.file.name);
this.data = this.data || {};
for (const key in this.data) {
if (this.data[key]) {
apiRequest.field(key, this.data[key]);
}
}
for (const key in this.data) if (this.data[key]) apiRequest.field(key, this.data[key]);
} else if (this.data) {
apiRequest.send(this.data);
}