Improve token "Bot" removal

This commit is contained in:
Schuyler Cebulskie
2016-10-14 02:11:31 -04:00
parent 6e76df2656
commit e4636243b2
3 changed files with 3 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ class RESTMethods {
}
loginToken(token = this.rest.client.token) {
token = token.replace('Bot ', '');
token = token.replace(/^Bot /, '');
return new Promise((resolve, reject) => {
this.rest.client.manager.connectToWebSocket(token, resolve, reject);
});

View File

@@ -72,7 +72,7 @@ class ShardingManager extends EventEmitter {
* Token to use for obtaining the automatic shard count, and passing to shards
* @type {?string}
*/
this.token = options.token;
this.token = options.token ? options.token.replace(/^Bot /, '') : null;
/**
* A collection of shards that this manager has spawned

View File

@@ -10,7 +10,7 @@ module.exports = function getRecommendedShards(token) {
return new Promise((resolve, reject) => {
if (!token) throw new Error('A token must be provided.');
superagent.get(botGateway)
.set('Authorization', `Bot ${token.replace('Bot ', '')}`)
.set('Authorization', `Bot ${token.replace(/^Bot /, '')}`)
.end((err, res) => {
if (err) reject(err);
resolve(res.body.shards);