From 53d767ec040b0bcf68f59b8fe9e1e42ea60d6b9f Mon Sep 17 00:00:00 2001 From: Amish Shah Date: Sat, 13 Aug 2016 12:25:01 +0100 Subject: [PATCH] some doc stuff idk --- src/client/Client.js | 22 ++++++++++++++++++++++ src/structures/User.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/src/client/Client.js b/src/client/Client.js index bd3ba133f..b47fba0c7 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -10,6 +10,13 @@ const ClientDataResolver = require('./ClientDataResolver'); const WebSocketManager = require('./websocket/WebSocketManager'); const ActionsManager = require('./actions/ActionsManager'); +/** + * Creates a new Discord Client + * ```js + * const Discord = require("discord.js"); + * const client = new Discord.Client(); + * ``` + */ class Client extends EventEmitter{ constructor(options) { @@ -23,6 +30,17 @@ class Client extends EventEmitter{ this.actions = new ActionsManager(this); } + /** + * Logs the client in. If successful, resolves with the account's token. + * @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} + * @example + * client.login("token"); + * // or + * client.login("email", "password"); + */ login(email, password) { if (password) { // login with email and password @@ -33,6 +51,10 @@ class Client extends EventEmitter{ } } + /** + * The User of the logged in Client, only available after `READY` has been fired. + * @return {ClientUser} [description] + */ get user() { return this.store.user; } diff --git a/src/structures/User.js b/src/structures/User.js index e635f4937..2563fccb2 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -2,6 +2,9 @@ const TextBasedChannel = require('./interface/TextBasedChannel'); +/** + * Represents a User on Discord. + */ class User { constructor(client, data) { this.client = client; @@ -11,11 +14,39 @@ class User { } setup(data) { + /** + * The username of the User + * @type {String} + */ this.username = data.username; + /** + * The ID of the User + * @type {String} + */ this.id = data.id; + /** + * A discriminator based on username for the User + * @type {String} + */ this.discriminator = data.discriminator; + /** + * The ID of the user's avatar + * @type {String} + */ this.avatar = data.avatar; + /** + * Whether or not the User is a Bot. + * @type {Boolean} + */ this.bot = Boolean(data.bot); + /** + * The status of the user: + * + * * **`online`** - user is online + * * **`offline`** - user is offline + * * **`idle`** - user is AFK + * @type {String} + */ this.status = data.status || this.status || 'offline'; this.game = data.game || this.game; } @@ -24,6 +55,10 @@ class User { return `<@${this.id}>`; } + /** + * Deletes a DM Channel (if one exists) between the Client and the User. Resolves with the Channel if successful. + * @return {Promise} + */ deleteDM() { return this.client.rest.methods.DeleteChannel(this); }