docs: Fixed some missing docstrings or incorrect return types (#2093)

* Fix some missing doc strings
Mainly just readonly tags

* Return an error when guild#allowDMs is ran from a bot account, and fix some return types

* WebhookClient implements Webhook, doesn't extend it

* Fix Client#rateLimit docs not showing what it returns

Cause I wanted to handle this event only to see no return props 🤔

* Actually make Client#rateLimit show the right info

Its an object with all the info
This commit is contained in:
Frangu Vlad
2017-11-17 15:20:57 +02:00
committed by Crawl
parent 6fa4fc532c
commit 0cd4a92fb8
8 changed files with 21 additions and 11 deletions

View File

@@ -42,6 +42,7 @@ class BaseClient extends EventEmitter {
/** /**
* API shortcut * API shortcut
* @type {Object} * @type {Object}
* @readonly
* @private * @private
*/ */
get api() { get api() {

View File

@@ -163,6 +163,7 @@ class Client extends BaseClient {
/** /**
* Timestamp of the latest ping's start time * Timestamp of the latest ping's start time
* @type {number} * @type {number}
* @readonly
* @private * @private
*/ */
get _pingTimestamp() { get _pingTimestamp() {

View File

@@ -3,7 +3,7 @@ const BaseClient = require('./BaseClient');
/** /**
* The webhook client. * The webhook client.
* @extends {Webhook} * @implements {Webhook}
* @extends {BaseClient} * @extends {BaseClient}
*/ */
class WebhookClient extends BaseClient { class WebhookClient extends BaseClient {

View File

@@ -39,12 +39,13 @@ class RequestHandler {
/** /**
* Emitted when the client hits a rate limit while making a request * Emitted when the client hits a rate limit while making a request
* @event Client#rateLimit * @event Client#rateLimit
* @prop {number} timeout Timeout in ms * @param {Object} rateLimitInfo Object containing the rate limit info
* @prop {number} limit Number of requests that can be made to this endpoint * @param {number} rateLimitInfo.timeout Timeout in ms
* @prop {number} timeDifference Delta-T in ms between your system and Discord servers * @param {number} rateLimitInfo.limit Number of requests that can be made to this endpoint
* @prop {string} method HTTP method used for request that triggered this event * @param {number} rateLimitInfo.timeDifference Delta-T in ms between your system and Discord servers
* @prop {string} path Path used for request that triggered this event * @param {string} rateLimitInfo.method HTTP method used for request that triggered this event
* @prop {string} route Route used for request that triggered this event * @param {string} rateLimitInfo.path Path used for request that triggered this event
* @param {string} rateLimitInfo.route Route used for request that triggered this event
*/ */
this.client.emit(RATE_LIMIT, { this.client.emit(RATE_LIMIT, {
timeout, timeout,

View File

@@ -248,7 +248,7 @@ class ClientUser extends User {
/** /**
* Fetches messages that mentioned the client's user. * Fetches messages that mentioned the client's user.
* <warn>This is only available when using a user account.</warn> * <warn>This is only available when using a user account.</warn>
* @param {Object} [options] Options for the fetch * @param {Object} [options={}] Options for the fetch
* @param {number} [options.limit=25] Maximum number of mentions to retrieve * @param {number} [options.limit=25] Maximum number of mentions to retrieve
* @param {boolean} [options.roles=true] Whether to include role mentions * @param {boolean} [options.roles=true] Whether to include role mentions
* @param {boolean} [options.everyone=true] Whether to include everyone/here mentions * @param {boolean} [options.everyone=true] Whether to include everyone/here mentions

View File

@@ -321,7 +321,7 @@ class Guild extends Base {
/** /**
* System channel for this guild * System channel for this guild
* @type {?GuildChannel} * @type {?TextChannel}
* @readonly * @readonly
*/ */
get systemChannel() { get systemChannel() {
@@ -806,6 +806,7 @@ class Guild extends Base {
* @returns {Promise<Guild>} * @returns {Promise<Guild>}
*/ */
allowDMs(allow) { allowDMs(allow) {
if (this.client.user.bot) return Promise.reject(new Error('FEATURE_USER_ONLY'));
const settings = this.client.user.settings; const settings = this.client.user.settings;
if (allow) return settings.removeRestrictedGuild(this); if (allow) return settings.removeRestrictedGuild(this);
else return settings.addRestrictedGuild(this); else return settings.addRestrictedGuild(this);
@@ -818,7 +819,7 @@ class Guild extends Base {
* string, the ban reason. Supplying an object allows you to do both. * string, the ban reason. Supplying an object allows you to do both.
* @param {number} [options.days=0] Number of days of messages to delete * @param {number} [options.days=0] Number of days of messages to delete
* @param {string} [options.reason] Reason for banning * @param {string} [options.reason] Reason for banning
* @returns {Promise<GuildMember|User|string>} Result object will be resolved as specifically as possible. * @returns {Promise<GuildMember|User|Snowflake>} Result object will be resolved as specifically as possible.
* If the GuildMember cannot be resolved, the User will instead be attempted to be resolved. If that also cannot * If the GuildMember cannot be resolved, the User will instead be attempted to be resolved. If that also cannot
* be resolved, the user ID will be the result. * be resolved, the user ID will be the result.
* @example * @example

View File

@@ -77,36 +77,42 @@ class GuildMember extends Base {
/** /**
* Whether this member is deafened server-wide * Whether this member is deafened server-wide
* @type {boolean} * @type {boolean}
* @readonly
*/ */
get serverDeaf() { return this.voiceState.deaf; } get serverDeaf() { return this.voiceState.deaf; }
/** /**
* Whether this member is muted server-wide * Whether this member is muted server-wide
* @type {boolean} * @type {boolean}
* @readonly
*/ */
get serverMute() { return this.voiceState.mute; } get serverMute() { return this.voiceState.mute; }
/** /**
* Whether this member is self-muted * Whether this member is self-muted
* @type {boolean} * @type {boolean}
* @readonly
*/ */
get selfMute() { return this.voiceState.self_mute; } get selfMute() { return this.voiceState.self_mute; }
/** /**
* Whether this member is self-deafened * Whether this member is self-deafened
* @type {boolean} * @type {boolean}
* @readonly
*/ */
get selfDeaf() { return this.voiceState.self_deaf; } get selfDeaf() { return this.voiceState.self_deaf; }
/** /**
* The voice session ID of this member (if any) * The voice session ID of this member (if any)
* @type {?Snowflake} * @type {?Snowflake}
* @readonly
*/ */
get voiceSessionID() { return this.voiceState.session_id; } get voiceSessionID() { return this.voiceState.session_id; }
/** /**
* The voice channel ID of this member, (if any) * The voice channel ID of this member, (if any)
* @type {?Snowflake} * @type {?Snowflake}
* @readonly
*/ */
get voiceChannelID() { return this.voiceState.channel_id; } get voiceChannelID() { return this.voiceState.channel_id; }

View File

@@ -52,7 +52,7 @@ exports.DefaultOptions = {
* WebSocket options (these are left as snake_case to match the API) * WebSocket options (these are left as snake_case to match the API)
* @typedef {Object} WebsocketOptions * @typedef {Object} WebsocketOptions
* @property {number} [large_threshold=250] Number of members in a guild to be considered large * @property {number} [large_threshold=250] Number of members in a guild to be considered large
* @property {boolean} [compress=true] Whether to compress data sent on the connection * @property {boolean} [compress=false] Whether to compress data sent on the connection
* (defaults to `false` for browsers) * (defaults to `false` for browsers)
*/ */
ws: { ws: {