From 0607720ec80eb7801daeae7e9ba59e85b8b8c20d Mon Sep 17 00:00:00 2001 From: Isabella Date: Thu, 7 Sep 2017 19:01:35 -0500 Subject: [PATCH] docs: improve documentation (#1898) * improve channel documentation * forgot some stuff * another one * im good at this * i did a dum --- src/client/actions/ChannelDelete.js | 2 +- .../packets/handlers/ChannelCreate.js | 6 ++--- .../packets/handlers/ChannelPinsUpdate.js | 6 ++--- .../packets/handlers/ChannelUpdate.js | 4 +-- src/structures/Guild.js | 2 +- src/structures/GuildAuditLogs.js | 26 ++++++++++++++++--- src/util/Collection.js | 4 +-- 7 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/client/actions/ChannelDelete.js b/src/client/actions/ChannelDelete.js index cfc012cc6..d91782b37 100644 --- a/src/client/actions/ChannelDelete.js +++ b/src/client/actions/ChannelDelete.js @@ -23,7 +23,7 @@ class ChannelDeleteAction extends Action { /** * Emitted whenever a channel is deleted. * @event Client#channelDelete - * @param {Channel} channel The channel that was deleted + * @param {GroupDMChannel|GuildChannel} channel The channel that was deleted */ module.exports = ChannelDeleteAction; diff --git a/src/client/websocket/packets/handlers/ChannelCreate.js b/src/client/websocket/packets/handlers/ChannelCreate.js index 57c235197..5ccc05708 100644 --- a/src/client/websocket/packets/handlers/ChannelCreate.js +++ b/src/client/websocket/packets/handlers/ChannelCreate.js @@ -6,10 +6,10 @@ class ChannelCreateHandler extends AbstractHandler { } } +module.exports = ChannelCreateHandler; + /** * Emitted whenever a channel is created. * @event Client#channelCreate - * @param {Channel} channel The channel that was created + * @param {DMChannel|GroupDMChannel|GuildChannel} channel The channel that was created */ - -module.exports = ChannelCreateHandler; diff --git a/src/client/websocket/packets/handlers/ChannelPinsUpdate.js b/src/client/websocket/packets/handlers/ChannelPinsUpdate.js index 636df81e5..e772c2083 100644 --- a/src/client/websocket/packets/handlers/ChannelPinsUpdate.js +++ b/src/client/websocket/packets/handlers/ChannelPinsUpdate.js @@ -20,12 +20,12 @@ class ChannelPinsUpdate extends AbstractHandler { } } +module.exports = ChannelPinsUpdate; + /** * Emitted whenever the pins of a channel are updated. Due to the nature of the WebSocket event, not much information * can be provided easily here - you need to manually check the pins yourself. * @event Client#channelPinsUpdate - * @param {Channel} channel The channel that the pins update occured in + * @param {DMChannel|GroupDMChannel|TextChannel} channel The channel that the pins update occured in * @param {Date} time The time of the pins update */ - -module.exports = ChannelPinsUpdate; diff --git a/src/client/websocket/packets/handlers/ChannelUpdate.js b/src/client/websocket/packets/handlers/ChannelUpdate.js index b57d3f304..0bf9e24c1 100644 --- a/src/client/websocket/packets/handlers/ChannelUpdate.js +++ b/src/client/websocket/packets/handlers/ChannelUpdate.js @@ -15,6 +15,6 @@ module.exports = ChannelUpdateHandler; /** * Emitted whenever a channel is updated - e.g. name change, topic change. * @event Client#channelUpdate - * @param {Channel} oldChannel The channel before the update - * @param {Channel} newChannel The channel after the update + * @param {DMChannel|GroupDMChannel|GuildChannel} oldChannel The channel before the update + * @param {DMChannel|GroupDMChannel|GuildChannel} newChannel The channel after the update */ diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 8db08151e..83715a492 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -499,7 +499,7 @@ class Guild extends Base { * @param {Snowflake|GuildAuditLogsEntry} [options.after] Limit to entries from after specified entry * @param {number} [options.limit] Limit number of entries * @param {UserResolvable} [options.user] Only show entries involving this user - * @param {string|number} [options.type] Only show entries involving this action type + * @param {ActionType|number} [options.type] Only show entries involving this action type * @returns {Promise} */ fetchAuditLogs(options = {}) { diff --git a/src/structures/GuildAuditLogs.js b/src/structures/GuildAuditLogs.js index da6ca48bd..1c077af5f 100644 --- a/src/structures/GuildAuditLogs.js +++ b/src/structures/GuildAuditLogs.js @@ -84,6 +84,19 @@ class GuildAuditLogs { return Promise.all(logs.entries.map(e => e.target)).then(() => logs); } + /** + * The target type of an entry, e.g. `GUILD`. Here are the available types: + * * GUILD + * * CHANNEL + * * USER + * * ROLE + * * INVITE + * * WEBHOOK + * * EMOJI + * * MESSAGE + * @typedef {string} TargetType + */ + /** * Find target type from entry action. * @param {number} target The action target @@ -101,6 +114,13 @@ class GuildAuditLogs { return Targets.UNKNOWN; } + /** + * The action type of an entry, e.g. `CREATE`. Here are the available types: + * * CREATE + * * DELETE + * * UPDATE + * @typedef {string} ActionType + */ /** * Find action type from entry action. @@ -155,13 +175,13 @@ class GuildAuditLogsEntry { const targetType = GuildAuditLogs.targetType(data.action_type); /** * The target type of this entry - * @type {string} + * @type {TargetType} */ this.targetType = targetType; /** * The action type of this entry - * @type {string} + * @type {ActionType} */ this.actionType = GuildAuditLogs.actionType(data.action_type); @@ -239,7 +259,7 @@ class GuildAuditLogsEntry { if (targetType === Targets.UNKNOWN) { /** * The target of this entry - * @type {Snowflake|Guild|User|Role|Emoji|Invite|Webhook} + * @type {TargetType} */ this.target = this.changes.reduce((o, c) => { o[c.key] = c.new || c.old; diff --git a/src/util/Collection.js b/src/util/Collection.js index 186fbb77d..1f3fc6307 100644 --- a/src/util/Collection.js +++ b/src/util/Collection.js @@ -413,10 +413,10 @@ class Collection extends Map { } /** - * The sort() method sorts the elements of a collection in place and returns the collection. + * The sort() method sorts the elements of a collection and returns it. * The sort is not necessarily stable. The default sort order is according to string Unicode code points. * @param {Function} [compareFunction] Specifies a function that defines the sort order. - * if omitted, the collection is sorted according to each character's Unicode code point value, + * If omitted, the collection is sorted according to each character's Unicode code point value, * according to the string conversion of each element. * @returns {Collection} */