Add 'Bot' prefix to token (#510)

* Add 'Bot' prefix to token

* Add option for token prefix

* Maybe this is what abal meant?

* Change option name

* Check if token already starts with prefix
This commit is contained in:
Hugo Holmqvist
2016-08-14 21:38:04 +03:00
committed by abal
parent 1963bcfa10
commit ce198ef005
3 changed files with 10 additions and 2 deletions

View File

@@ -64,6 +64,11 @@ shardId
A zero-based integer representing the value of the current shard.
bot
~~~~~~~
Boolean. Use 'Bot my_token' when authorizing. Default is true, should be false if user bot.
--------
Attributes

View File

@@ -54,6 +54,7 @@ export default class Client extends EventEmitter {
this.options.shardId = options.shardId || 0;
this.options.shardCount = options.shardCount || 0;
this.options.disableEveryone = options.disableEveryone || false;
this.options.bot = options.bot === undefined || options.bot === true ? true : false;
if (typeof options.shardCount === "number" && typeof options.shardId === "number" && options.shardCount > 0) {
this.options.shard = [options.shardId, options.shardCount];

View File

@@ -521,10 +521,12 @@ export default class InternalClient {
this.email = email;
this.password = password;
var self = this;
return this.getGateway()
.then(url => {
this.createWS(url);
return token;
self.token = self.client.options.bot && !self.token.startsWith("Bot ") ? `Bot ${self.token}` : self.token;
self.createWS(url);
return self.token;
});
}