mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
Make token "Bot" removal more lenient
In case of heavy user error. :)
This commit is contained in:
@@ -15,7 +15,7 @@ class RESTMethods {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loginToken(token = this.rest.client.token) {
|
loginToken(token = this.rest.client.token) {
|
||||||
token = token.replace(/^Bot /, '');
|
token = token.replace(/^Bot\s*/i, '');
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.rest.client.manager.connectToWebSocket(token, resolve, reject);
|
this.rest.client.manager.connectToWebSocket(token, resolve, reject);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class ShardingManager extends EventEmitter {
|
|||||||
* Token to use for obtaining the automatic shard count, and passing to shards
|
* Token to use for obtaining the automatic shard count, and passing to shards
|
||||||
* @type {?string}
|
* @type {?string}
|
||||||
*/
|
*/
|
||||||
this.token = options.token ? options.token.replace(/^Bot /, '') : null;
|
this.token = options.token ? options.token.replace(/^Bot\s*/i, '') : null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of shards that this manager has spawned
|
* A collection of shards that this manager has spawned
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ module.exports = function getRecommendedShards(token) {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!token) throw new Error('A token must be provided.');
|
if (!token) throw new Error('A token must be provided.');
|
||||||
superagent.get(botGateway)
|
superagent.get(botGateway)
|
||||||
.set('Authorization', `Bot ${token.replace(/^Bot /, '')}`)
|
.set('Authorization', `Bot ${token.replace(/^Bot\s*/i, '')}`)
|
||||||
.end((err, res) => {
|
.end((err, res) => {
|
||||||
if (err) reject(err);
|
if (err) reject(err);
|
||||||
resolve(res.body.shards);
|
resolve(res.body.shards);
|
||||||
|
|||||||
Reference in New Issue
Block a user