From 736fa7c6113e549762572def4a5746194545a058 Mon Sep 17 00:00:00 2001 From: Will Nelson Date: Sat, 17 Dec 2016 10:22:39 -0800 Subject: [PATCH] friendlier notification of an invalid token (#997) * friendlier notification of an invalid token * fixed * even fixeder * no token -> invalid token * eslint * Update RESTMethods.js --- src/client/rest/RESTMethods.js | 1 + src/util/Constants.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/client/rest/RESTMethods.js b/src/client/rest/RESTMethods.js index 7d996deda..8241a4464 100644 --- a/src/client/rest/RESTMethods.js +++ b/src/client/rest/RESTMethods.js @@ -18,6 +18,7 @@ class RESTMethods { login(token = this.rest.client.token) { return new Promise((resolve, reject) => { + if (typeof token !== 'string') throw new Error(Constants.Errors.INVALID_TOKEN); token = token.replace(/^Bot\s*/i, ''); this.rest.client.manager.connectToWebSocket(token, resolve, reject); }); diff --git a/src/util/Constants.js b/src/util/Constants.js index 462593bda..93453e6d4 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -68,6 +68,7 @@ exports.Errors = { INVALID_RATE_LIMIT_METHOD: 'Unknown rate limiting method.', BAD_LOGIN: 'Incorrect login details were provided.', INVALID_SHARD: 'Invalid shard settings were provided.', + INVALID_TOKEN: 'An invalid token was provided.', }; const PROTOCOL_VERSION = exports.PROTOCOL_VERSION = 6;