rewrite endpoints for consistancy and modularity (#1323)

* rewrite endpoints for consistancy and modularity

* clean up a bit

* add missing endpoint
This commit is contained in:
Gus Caplan
2017-03-31 12:36:09 -05:00
committed by Amish Shah
parent 1cb227d6d8
commit 1df3b84da6
5 changed files with 223 additions and 215 deletions

View File

@@ -1,5 +1,5 @@
const superagent = require('superagent');
const botGateway = require('./Constants').Endpoints.botGateway;
const Constants = require('./Constants');
/**
* Contains various general-purpose utility methods. These functions are also available on the base `Discord` object.
@@ -54,7 +54,7 @@ class Util {
static fetchRecommendedShards(token, guildsPerShard = 1000) {
return new Promise((resolve, reject) => {
if (!token) throw new Error('A token must be provided.');
superagent.get(botGateway)
superagent.get(Constants.Endpoints.gateway.bot)
.set('Authorization', `Bot ${token.replace(/^Bot\s*/i, '')}`)
.end((err, res) => {
if (err) reject(err);