From ce198ef005a8eb55d9cd9e8d76309f9cbe53e1ef Mon Sep 17 00:00:00 2001 From: Hugo Holmqvist Date: Sun, 14 Aug 2016 21:38:04 +0300 Subject: [PATCH] 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 --- docs/docs_client.rst | 5 +++++ src/Client/Client.js | 1 + src/Client/InternalClient.js | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/docs_client.rst b/docs/docs_client.rst index 79e29b717..b4dfe918b 100755 --- a/docs/docs_client.rst +++ b/docs/docs_client.rst @@ -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 diff --git a/src/Client/Client.js b/src/Client/Client.js index 2be337ba6..712ec7200 100755 --- a/src/Client/Client.js +++ b/src/Client/Client.js @@ -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]; diff --git a/src/Client/InternalClient.js b/src/Client/InternalClient.js index 3af7ec6a8..342b2f0b1 100755 --- a/src/Client/InternalClient.js +++ b/src/Client/InternalClient.js @@ -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; }); }