Merge branch 'master' into indev-prism

This commit is contained in:
Amish Shah
2017-02-22 20:37:59 +00:00
48 changed files with 738 additions and 420 deletions

View File

@@ -1,7 +1,7 @@
const os = require('os');
const EventEmitter = require('events').EventEmitter;
const mergeDefault = require('../util/MergeDefault');
const Constants = require('../util/Constants');
const Util = require('../util/Util');
const RESTManager = require('./rest/RESTManager');
const ClientDataManager = require('./ClientDataManager');
const ClientManager = require('./ClientManager');
@@ -33,7 +33,7 @@ class Client extends EventEmitter {
* The options the client was instantiated with
* @type {ClientOptions}
*/
this.options = mergeDefault(Constants.DefaultOptions, options);
this.options = Util.mergeDefault(Constants.DefaultOptions, options);
this._validateOptions();
/**
@@ -44,42 +44,42 @@ class Client extends EventEmitter {
this.rest = new RESTManager(this);
/**
* The data manager of the Client
* The data manager of the client
* @type {ClientDataManager}
* @private
*/
this.dataManager = new ClientDataManager(this);
/**
* The manager of the Client
* The manager of the client
* @type {ClientManager}
* @private
*/
this.manager = new ClientManager(this);
/**
* The WebSocket Manager of the Client
* The WebSocket manager of the client
* @type {WebSocketManager}
* @private
*/
this.ws = new WebSocketManager(this);
/**
* The Data Resolver of the Client
* The data resolver of the client
* @type {ClientDataResolver}
* @private
*/
this.resolver = new ClientDataResolver(this);
/**
* The Action Manager of the Client
* The action manager of the client
* @type {ActionsManager}
* @private
*/
this.actions = new ActionsManager(this);
/**
* The Voice Manager of the Client (`null` in browsers)
* The voice manager of the client (`null` in browsers)
* @type {?ClientVoiceManager}
* @private
*/
@@ -155,8 +155,25 @@ class Client extends EventEmitter {
*/
this.pings = [];
/**
* Timestamp of the latest ping's start time
* @type {number}
* @private
*/
this._pingTimestamp = 0;
/**
* Timeouts set by {@link Client#setTimeout} that are still active
* @type {Set<Timeout>}
* @private
*/
this._timeouts = new Set();
/**
* Intervals set by {@link Client#setInterval} that are still active
* @type {Set<Timeout>}
* @private
*/
this._intervals = new Set();
if (this.options.messageSweepInterval > 0) {
@@ -258,7 +275,7 @@ class Client extends EventEmitter {
}
/**
* Logs out, terminates the connection to Discord, and destroys the client
* Logs out, terminates the connection to Discord, and destroys the client.
* @returns {Promise}
*/
destroy() {
@@ -361,12 +378,11 @@ class Client extends EventEmitter {
/**
* Obtains the OAuth Application of the bot from Discord.
* <warn>This is only available when using a bot account.</warn>
* @param {Snowflake} [id='@me'] ID of application to fetch
* @returns {Promise<ClientOAuth2Application>}
*/
fetchApplication() {
if (!this.user.bot) throw new Error(Constants.Errors.NO_BOT_ACCOUNT);
return this.rest.methods.getMyApplication();
fetchApplication(id = '@me') {
return this.rest.methods.getApplication(id);
}
/**
@@ -408,7 +424,7 @@ class Client extends EventEmitter {
}
/**
* Clears a timeout
* Clears a timeout.
* @param {Timeout} timeout Timeout to cancel
*/
clearTimeout(timeout) {
@@ -430,7 +446,7 @@ class Client extends EventEmitter {
}
/**
* Clears an interval
* Clears an interval.
* @param {Timeout} interval Interval to cancel
*/
clearInterval(interval) {
@@ -464,7 +480,8 @@ class Client extends EventEmitter {
}
/**
* Calls `eval(script)` with the client as `this`.
* Calls {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval} on a script
* with the client as `this`.
* @param {string} script Script to eval
* @returns {*}
* @private
@@ -474,7 +491,7 @@ class Client extends EventEmitter {
}
/**
* Validates client options
* Validates the client options.
* @param {ClientOptions} [options=this.options] Options to validate
* @private
*/