Make JSDocs follow general conventions (#582)

* Make JSDocs follow usual conventions

* Fix StringResolvable name

* Make function lowercase
This commit is contained in:
Schuyler Cebulskie
2016-09-03 04:57:25 -04:00
committed by Amish Shah
parent 44efcf3f52
commit 27652b94af
33 changed files with 262 additions and 262 deletions

View File

@@ -67,22 +67,22 @@ class Client extends EventEmitter {
this.voice = new ClientVoiceManager(this);
/**
* A Collection of the Client's stored users
* @type {Collection<String, User>}
* @type {Collection<string, User>}
*/
this.users = new Collection();
/**
* A Collection of the Client's stored guilds
* @type {Collection<String, Guild>}
* @type {Collection<string, Guild>}
*/
this.guilds = new Collection();
/**
* A Collection of the Client's stored channels
* @type {Collection<String, Channel>}
* @type {Collection<string, Channel>}
*/
this.channels = new Collection();
/**
* The authorization token for the logged in user/bot.
* @type {?String}
* @type {?string}
*/
this.token = null;
/**
@@ -92,17 +92,17 @@ class Client extends EventEmitter {
this.user = null;
/**
* The email, if there is one, for the logged in Client
* @type {?String}
* @type {?string}
*/
this.email = null;
/**
* The password, if there is one, for the logged in Client
* @type {?String}
* @type {?string}
*/
this.password = null;
/**
* The time in milliseconds the Client connected
* @type {?Number}
* @type {?number}
*/
this.readyTime = null;
this._intervals = [];
@@ -114,10 +114,10 @@ class Client extends EventEmitter {
* much better to use a bot account rather than a user account.
* Bot accounts have higher rate limits and have access to some features user accounts don't have. User bots
* that are making a lot of API requests can even be banned.</warn>
* @param {String} emailOrToken The email or token used for the account. If it is an email, a password _must_ be
* @param {string} emailOrToken The email or token used for the account. If it is an email, a password _must_ be
* provided.
* @param {String} [password] The password for the account, only needed if an email was provided.
* @return {Promise<String>}
* @param {string} [password] The password for the account, only needed if an email was provided.
* @return {Promise<string>}
* @example
* // log the client in using a token
* const token = 'my token';
@@ -176,7 +176,7 @@ class Client extends EventEmitter {
/**
* Caches a user, or obtains it from the cache if it's already cached.
* If the user isn't already cached, it will only be obtainable by OAuth bot accounts.
* @param {String} id The ID of the user to obtain
* @param {string} id The ID of the user to obtain
* @return {Promise<User>}
*/
fetchUser(id) {
@@ -187,7 +187,7 @@ class Client extends EventEmitter {
/**
* Returns a Collection, mapping Guild ID to Voice Connections.
* @readonly
* @type {Collection<String, VoiceConnection>}
* @type {Collection<string, VoiceConnection>}
*/
get voiceConnections() {
return this.voice.connections;
@@ -196,7 +196,7 @@ class Client extends EventEmitter {
/**
* The uptime for the logged in Client.
* @readonly
* @type {?Number}
* @type {?number}
*/
get uptime() {
return this.readyTime ? Date.now() - this.readyTime : null;

View File

@@ -106,13 +106,13 @@ class ClientDataResolver {
* Data that resolves to give a Base64 string, typically for image uploading. This can be:
* * A Buffer
* * A Base64 String
* @typedef {Buffer|String} Base64Resolvable
* @typedef {Buffer|string} Base64Resolvable
*/
/**
* Resolves a Base64Resolvable to a Base 64 image
* @param {Base64Resolvable} dataResolvable the base 64 resolvable you want to resolve
* @returns {?String}
* @returns {?string}
*/
resolveBase64(data) {
if (data instanceof Buffer) {
@@ -126,7 +126,7 @@ class ClientDataResolver {
* Data that can be resolved to give a Channel. This can be:
* * An instance of a Channel
* * An ID of a Channel
* @typedef {Channel|String} ChannelResolvable
* @typedef {Channel|string} ChannelResolvable
*/
/**
@@ -151,13 +151,13 @@ class ClientDataResolver {
* * A String
* * An Array (joined with a new line delimiter to give a string)
* * Any object
* @typedef {String|Array|Object} StringResolvable
* @typedef {string|Array|Object} StringResolvable
*/
/**
* Resolves a StringResolvable to a String
* @param {StringResolvable} stringResolvable the string resolvable to resolve
* @returns {String}
* @param {StringResolvable} StringResolvable the string resolvable to resolve
* @returns {string}
*/
resolveString(data) {
if (data instanceof String) {
@@ -176,13 +176,13 @@ class ClientDataResolver {
* * A Buffer
* * The path to a local file
* * An URL
* @typedef {String|Buffer} FileResolvable
* @typedef {string|Buffer} FileResolvable
*/
/**
* Resolves a FileResolvable to a Buffer
* @param {FileResolvable} fileResolvable the file resolvable to resolve
* @returns {String|Buffer}
* @returns {string|Buffer}
*/
resolveFile(resource) {
if ($string(resource)) {

View File

@@ -14,17 +14,17 @@ class ClientManager {
this.client = client;
/**
* The heartbeat interval, null if not yet set
* @type {?Number}
* @type {?number}
*/
this.heartbeatInterval = null;
}
/**
* Connects the Client to the WebSocket
* @param {String} token the authorization token
* @param {Function} resolve function to run when connection is successful
* @param {Function} reject function to run when connection fails
* @returns {null}
* @param {string} token the authorization token
* @param {function} resolve function to run when connection is successful
* @param {function} reject function to run when connection fails
* @returns {void}
*/
connectToWebSocket(token, resolve, reject) {
this.client.token = token;
@@ -40,8 +40,8 @@ class ClientManager {
/**
* Sets up a keep-alive interval to keep the Client's connection valid
* @param {Number} time the interval in milliseconds at which heartbeat packets should be sent
* @returns {null}
* @param {number} time the interval in milliseconds at which heartbeat packets should be sent
* @returns {void}
*/
setupKeepAlive(time) {
this.heartbeatInterval = this.client.setInterval(() => {

View File

@@ -19,7 +19,7 @@ class RequestHandler {
/**
* Whether or not the client is being rate limited on every endpoint.
* @type {Boolean}
* @type {boolean}
*/
get globalLimit() {
return this.restManager.globallyRateLimited;

View File

@@ -14,20 +14,20 @@ class SequentialRequestHandler extends RequestHandler {
/**
* Whether this rate limiter is waiting for a response from a request
* @type {Boolean}
* @type {boolean}
*/
this.waiting = false;
/**
* The endpoint that this handler is handling
* @type {String}
* @type {string}
*/
this.endpoint = endpoint;
/**
* The time difference between Discord's Dates and the local computer's Dates. A positive number means the local
* computer's time is ahead of Discord's.
* @type {Number}
* @type {number}
*/
this.timeDifference = 0;
}

View File

@@ -16,12 +16,12 @@ class ClientVoiceManager {
this.client = client;
/**
* A collection mapping connection IDs to the Connection objects
* @type {Collection<String, VoiceConnection>}
* @type {Collection<string, VoiceConnection>}
*/
this.connections = new Collection();
/**
* Pending connection attempts, maps Guild ID to VoiceChannel
* @type {Collection<String, VoiceChannel>}
* @type {Collection<string, VoiceChannel>}
*/
this.pending = new Collection();
}
@@ -29,7 +29,7 @@ class ClientVoiceManager {
/**
* Checks whether a pending request can be processed
* @private
* @param {String} guildID The ID of the Guild
* @param {string} guildID The ID of the Guild
*/
_checkPendingReady(guildID) {
const pendingRequest = this.pending.get(guildID);
@@ -49,9 +49,9 @@ class ClientVoiceManager {
/**
* Called when the Client receives information about this voice server update.
* @param {String} guildID the ID of the Guild
* @param {String} token the token to authorise with
* @param {String} endpoint the endpoint to connect to
* @param {string} guildID the ID of the Guild
* @param {string} token the token to authorise with
* @param {string} endpoint the endpoint to connect to
*/
_receivedVoiceServer(guildID, token, endpoint) {
const pendingRequest = this.pending.get(guildID);
@@ -66,8 +66,8 @@ class ClientVoiceManager {
/**
* Called when the Client receives information about the voice state update.
* @param {String} guildID the ID of the Guild
* @param {String} sessionID the session id to authorise with
* @param {string} guildID the ID of the Guild
* @param {string} sessionID the session id to authorise with
*/
_receivedVoiceStateUpdate(guildID, sessionID) {
const pendingRequest = this.pending.get(guildID);
@@ -99,7 +99,7 @@ class ClientVoiceManager {
/**
* Sets up a request to join a voice channel
* @param {VoiceChannel} channel the voice channel to join
* @returns {null}
* @returns {void}
*/
joinChannel(channel) {
return new Promise((resolve, reject) => {

View File

@@ -25,7 +25,7 @@ class VoiceConnection extends EventEmitter {
this.player = new DefaultPlayer(this);
/**
* The endpoint of the connection
* @type {String}
* @type {string}
*/
this.endpoint = endpoint;
/**
@@ -41,18 +41,18 @@ class VoiceConnection extends EventEmitter {
this.websocket = new VoiceConnectionWebSocket(this, channel.guild.id, token, sessionID, endpoint);
/**
* Whether or not the connection is ready
* @type {Boolean}
* @type {boolean}
*/
this.ready = false;
/**
* The resolve function for the promise associated with creating this connection
* @type {Function}
* @type {function}
* @private
*/
this._resolve = resolve;
/**
* The reject function for the promise associated with creating this connection
* @type {Function}
* @type {function}
* @private
*/
this._reject = reject;
@@ -66,7 +66,7 @@ class VoiceConnection extends EventEmitter {
* Executed whenever an error occurs with the UDP/WebSocket sub-client
* @private
* @param {Error} error
* @returns {null}
* @returns {void}
*/
_onError(e) {
this._reject(e);
@@ -82,7 +82,7 @@ class VoiceConnection extends EventEmitter {
/**
* Disconnects the Client from the Voice Channel
* @param {string} [reason='user requested'] the reason of the disconnection
* @returns {null}
* @returns {void}
*/
disconnect(reason = 'user requested') {
this.manager.client.ws.send({
@@ -122,7 +122,7 @@ class VoiceConnection extends EventEmitter {
/**
* Binds listeners to the WebSocket and UDP sub-clients
* @returns {null}
* @returns {void}
* @private
*/
bindListeners() {
@@ -195,7 +195,7 @@ class VoiceConnection extends EventEmitter {
* Emitted whenever a user starts/stops speaking
* @event VoiceConnection#speaking
* @param {User} user the user that has started/stopped speaking
* @param {Boolean} speaking whether or not the user is speaking
* @param {boolean} speaking whether or not the user is speaking
*/
if (this.ready) {
this.emit('speaking', user, data.speaking);
@@ -208,7 +208,7 @@ class VoiceConnection extends EventEmitter {
/**
* Play the given file in the voice connection
* @param {String} filepath the path to the file
* @param {string} filepath the path to the file
* @returns {StreamDispatcher}
* @example
* // play files natively

View File

@@ -26,7 +26,7 @@ class StreamDispatcher extends EventEmitter {
/**
* Emitted when the dispatcher starts/stops speaking
* @event StreamDispatcher#speaking
* @param {Boolean} value whether or not the dispatcher is speaking
* @param {boolean} value whether or not the dispatcher is speaking
*/
_setSpeaking(value) {
this.speaking = value;
@@ -129,7 +129,7 @@ class StreamDispatcher extends EventEmitter {
/**
* Emitted when the stream wants to give debug information.
* @event StreamDispatcher#debug
* @param {String} information the debug information
* @param {string} information the debug information
*/
this.emit('debug', `triggered terminal state ${state} - stream is now dead`);
this._triggered = true;
@@ -172,7 +172,7 @@ class StreamDispatcher extends EventEmitter {
/**
* Stops the current stream permanently and emits an `end` event.
* @returns {null}
* @returns {void}
*/
end() {
this._triggerTerminalState('end', 'user requested');
@@ -180,7 +180,7 @@ class StreamDispatcher extends EventEmitter {
/**
* Stops sending voice packets to the voice connection (stream may still progress however)
* @returns {null}
* @returns {void}
*/
pause() {
this._pause(true);
@@ -188,7 +188,7 @@ class StreamDispatcher extends EventEmitter {
/**
* Resumes sending voice packets to the voice connection (may be further on in the stream than when paused)
* @returns {null}
* @returns {void}
*/
resume() {
this._pause(false);

View File

@@ -89,7 +89,7 @@ class VoiceReceiver extends EventEmitter {
/**
* Emitted whenever a voice packet cannot be decrypted
* @event VoiceReceiver#warn
* @param {String} message the warning message
* @param {string} message the warning message
*/
return this.emit('warn', 'failed to decrypt voice packet');
}

View File

@@ -23,33 +23,33 @@ class WebSocketManager {
this.packetManager = new PacketManager(this);
/**
* The status of the WebSocketManager, a type of Constants.Status. It defaults to IDLE.
* @type {Number}
* @type {number}
*/
this.status = Constants.Status.IDLE;
/**
* The session ID of the connection, null if not yet available.
* @type {?String}
* @type {?string}
*/
this.sessionID = null;
/**
* The packet count of the client, null if not yet available.
* @type {?Number}
* @type {?number}
*/
this.sequence = -1;
/**
* The gateway address for this WebSocket connection, null if not yet available.
* @type {?String}
* @type {?string}
*/
this.gateway = null;
}
/**
* Connects the client to a given gateway
* @param {String} gateway the gateway to connect to
* @returns {null}
* @param {string} gateway the gateway to connect to
* @returns {void}
*/
connect(gateway) {
this.status = Constants.Status.CONNECTING;
@@ -69,7 +69,7 @@ class WebSocketManager {
/**
* Sends a packet to the gateway
* @param {Object} packet An object that can be JSON stringified
* @returns {null}
* @returns {void}
*/
send(data) {
this._queue.push(JSON.stringify(data));
@@ -100,7 +100,7 @@ class WebSocketManager {
/**
* Run whenever the gateway connections opens up
* @returns {null}
* @returns {void}
*/
eventOpen() {
if (this.reconnecting) {
@@ -112,7 +112,7 @@ class WebSocketManager {
/**
* Sends a gatway resume packet, in cases of unexpected disconnections.
* @returns {null}
* @returns {void}
*/
_sendResume() {
const payload = {
@@ -129,7 +129,7 @@ class WebSocketManager {
/**
* Sends a new identification packet, in cases of new connections or failed reconnections.
* @returns {null}
* @returns {void}
*/
_sendNewIdentify() {
this.reconnecting = false;
@@ -147,7 +147,7 @@ class WebSocketManager {
/**
* Run whenever the connection to the gateway is closed, it will try to reconnect the client.
* @returns {null}
* @returns {void}
*/
eventClose(event) {
if (event.code === 4004) {
@@ -162,7 +162,7 @@ class WebSocketManager {
* Run whenever a message is received from the WebSocket. Returns `true` if the message
* was handled properly.
* @param {Object} data the received websocket data
* @returns {Boolean}
* @returns {boolean}
*/
eventMessage($event) {
let packet;
@@ -188,7 +188,7 @@ class WebSocketManager {
/**
* Run whenever an error occurs with the WebSocket connection. Tries to reconnect
* @returns {null}
* @returns {void}
*/
eventError(e) {
/**
@@ -214,7 +214,7 @@ class WebSocketManager {
/**
* Runs on new packets before `READY` to see if the Client is ready yet, if it is prepares
* the `READY` event.
* @returns {null}
* @returns {void}
*/
checkIfReady() {
if (this.status !== Constants.Status.READY && this.status !== Constants.Status.NEARLY) {
@@ -238,7 +238,7 @@ class WebSocketManager {
/**
* Tries to reconnect the client, changing the status to Constants.Status.RECONNECTING.
* @returns {null}
* @returns {void}
*/
tryReconnect() {
this.status = Constants.Status.RECONNECTING;

View File

@@ -15,7 +15,7 @@ class MessageDeleteBulkHandler extends AbstractHandler {
* Emitted whenever a messages are deleted in bulk
*
* @event Client#messageDeleteBulk
* @param {Collection<String, Message>} messages The deleted messages, mapped by their ID
* @param {Collection<string, Message>} messages The deleted messages, mapped by their ID
*/
module.exports = MessageDeleteBulkHandler;