From e0efcc6ab0e3f060e30438c0d990c9465c6134df Mon Sep 17 00:00:00 2001 From: Rodry <38259440+ImRodry@users.noreply.github.com> Date: Thu, 24 Jun 2021 09:55:44 +0100 Subject: [PATCH] docs(*): add links to Discord's API objects & data (#5862) --- src/managers/ApplicationCommandManager.js | 9 +++++++-- src/rest/DiscordAPIError.js | 7 ++++++- src/structures/APIMessage.js | 18 ++++++++++++++--- src/structures/ApplicationCommand.js | 14 +++++++++++-- src/structures/Channel.js | 5 +++++ src/structures/ClientPresence.js | 2 +- src/structures/ClientUser.js | 10 +++++++--- src/structures/CommandInteraction.js | 20 ++++++++++++------- src/structures/DMChannel.js | 2 +- src/structures/Emoji.js | 7 ++++++- src/structures/Guild.js | 5 +++++ src/structures/GuildBan.js | 7 ++++++- src/structures/GuildChannel.js | 2 +- src/structures/GuildEmoji.js | 4 ++-- src/structures/GuildMember.js | 7 ++++++- src/structures/GuildTemplate.js | 13 ++++++++---- src/structures/Interaction.js | 2 +- src/structures/InteractionWebhook.js | 2 +- src/structures/Message.js | 8 ++++---- src/structures/MessageActionRow.js | 7 ++++++- src/structures/MessageAttachment.js | 7 ++++++- src/structures/MessageButton.js | 2 +- src/structures/MessageComponentInteraction.js | 2 +- src/structures/MessageEmbed.js | 7 ++++++- src/structures/MessageReaction.js | 7 ++++++- src/structures/PermissionOverwrites.js | 4 +--- src/structures/Presence.js | 8 +++++++- src/structures/Role.js | 7 ++++++- src/structures/TextChannel.js | 2 +- src/structures/User.js | 7 ++++++- src/structures/VoiceState.js | 7 ++++++- src/structures/Webhook.js | 15 +++++++------- .../interfaces/InteractionResponses.js | 6 +++--- src/structures/interfaces/TextBasedChannel.js | 2 +- src/util/Util.js | 4 ++-- 35 files changed, 175 insertions(+), 63 deletions(-) diff --git a/src/managers/ApplicationCommandManager.js b/src/managers/ApplicationCommandManager.js index 6a214d817..8b5101473 100644 --- a/src/managers/ApplicationCommandManager.js +++ b/src/managers/ApplicationCommandManager.js @@ -193,7 +193,7 @@ class ApplicationCommandManager extends BaseManager { /** * Transforms an {@link ApplicationCommandData} object into something that can be used with the API. * @param {ApplicationCommandData} command The command to transform - * @returns {Object} + * @returns {APIApplicationCommand} * @private */ static transformCommand(command) { @@ -326,7 +326,7 @@ class ApplicationCommandManager extends BaseManager { * Transforms an {@link ApplicationCommandPermissionData} object into something that can be used with the API. * @param {ApplicationCommandPermissionData} permissions The permissions to transform * @param {boolean} [received] Whether these permissions have been received from Discord - * @returns {Object} + * @returns {APIApplicationCommandPermissions} * @private */ static transformPermissions(permissions, received) { @@ -342,3 +342,8 @@ class ApplicationCommandManager extends BaseManager { } module.exports = ApplicationCommandManager; + +/** + * @external APIApplicationCommandPermissions + * @see {@link https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissions} + */ diff --git a/src/rest/DiscordAPIError.js b/src/rest/DiscordAPIError.js index af060da30..cc62512a4 100644 --- a/src/rest/DiscordAPIError.js +++ b/src/rest/DiscordAPIError.js @@ -47,7 +47,7 @@ class DiscordAPIError extends Error { /** * Flattens an errors object returned from the API into an array. - * @param {Object} obj Discord errors object + * @param {APIError} obj Discord errors object * @param {string} [key] Used internally to determine key names of nested fields * @returns {string[]} * @private @@ -75,3 +75,8 @@ class DiscordAPIError extends Error { } module.exports = DiscordAPIError; + +/** + * @external APIError + * @see {@link https://discord.com/developers/docs/reference#error-messages} + */ diff --git a/src/structures/APIMessage.js b/src/structures/APIMessage.js index db467bfac..921d8a96c 100644 --- a/src/structures/APIMessage.js +++ b/src/structures/APIMessage.js @@ -31,13 +31,20 @@ class APIMessage { /** * Data sendable to the API - * @type {?Object} + * @type {?APIMessageRaw} */ this.data = null; + /** + * @typedef {Object} MessageFile + * @property {Buffer|string|Stream} attachment The original attachment that generated this file + * @property {string} name The name of this file + * @property {Buffer|Stream} file The file to be sent to the API + */ + /** * Files sendable to the API - * @type {?Object[]} + * @type {?MessageFile[]} */ this.files = null; } @@ -259,7 +266,7 @@ class APIMessage { /** * Resolves a single file into an object sendable to the API. * @param {BufferResolvable|Stream|FileOptions|MessageAttachment} fileLike Something that could be resolved to a file - * @returns {Object} + * @returns {MessageFile} */ static async resolveFile(fileLike) { let attachment; @@ -313,3 +320,8 @@ module.exports = APIMessage; * @typedef {TextChannel|DMChannel|User|GuildMember|Webhook|WebhookClient|Interaction|InteractionWebhook| * Message|MessageManager} MessageTarget */ + +/** + * @external APIMessageRaw + * @see {@link https://discord.com/developers/docs/resources/channel#message-object} + */ diff --git a/src/structures/ApplicationCommand.js b/src/structures/ApplicationCommand.js index 43ec79a99..b3444406c 100644 --- a/src/structures/ApplicationCommand.js +++ b/src/structures/ApplicationCommand.js @@ -206,13 +206,13 @@ class ApplicationCommand extends Base { * Transforms an {@link ApplicationCommandOptionData} object into something that can be used with the API. * @param {ApplicationCommandOptionData} option The option to transform * @param {boolean} [received] Whether this option has been received from Discord - * @returns {Object} + * @returns {APIApplicationCommandOption} * @private */ static transformOption(option, received) { const stringType = typeof option.type === 'string' ? option.type : ApplicationCommandOptionTypes[option.type]; return { - type: typeof option.type === 'number' && !received ? option.type : ApplicationCommandOptionTypes[option.type], + type: typeof option.type === 'number' && !received ? option.type : stringType, name: option.name, description: option.description, required: @@ -224,3 +224,13 @@ class ApplicationCommand extends Base { } module.exports = ApplicationCommand; + +/** + * @external APIApplicationCommand + * @see {@link https://discord.com/developers/docs/interactions/slash-commands#applicationcommand} + */ + +/** + * @external APIApplicationCommandOption + * @see {@link https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption} + */ diff --git a/src/structures/Channel.js b/src/structures/Channel.js index c86c9c8ff..ff12ed949 100644 --- a/src/structures/Channel.js +++ b/src/structures/Channel.js @@ -165,3 +165,8 @@ class Channel extends Base { } module.exports = Channel; + +/** + * @external APIChannel + * @see {@link https://discord.com/developers/docs/resources/channel#channel-object} + */ diff --git a/src/structures/ClientPresence.js b/src/structures/ClientPresence.js index 7b2f77510..7feba5a16 100644 --- a/src/structures/ClientPresence.js +++ b/src/structures/ClientPresence.js @@ -7,7 +7,7 @@ const { ActivityTypes, OPCodes } = require('../util/Constants'); class ClientPresence extends Presence { /** * @param {Client} client The instantiating client - * @param {Object} [data={}] The data for the client presence + * @param {APIPresence} [data={}] The data for the client presence */ constructor(client, data = {}) { super(client, Object.assign(data, { status: data.status || 'online', user: { id: null } })); diff --git a/src/structures/ClientUser.js b/src/structures/ClientUser.js index 79eae6463..8a36e2435 100644 --- a/src/structures/ClientUser.js +++ b/src/structures/ClientUser.js @@ -48,7 +48,7 @@ class ClientUser extends Structures.get('User') { /** * Edits the logged in client. - * @param {Object} data The new data + * @param {APIModifyClientData} data The new data * @param {string} [data.username] The new username * @param {BufferResolvable|Base64Resolvable} [data.avatar] The new avatar */ @@ -143,8 +143,7 @@ class ClientUser extends Structures.get('User') { /** * Options for setting an activity. - * @typedef ActivityOptions - * @type {Object} + * @typedef {Object} ActivityOptions * @property {string} [name] Name of the activity * @property {string} [url] Twitch / YouTube stream URL * @property {ActivityType|number} [type] Type of the activity @@ -179,3 +178,8 @@ class ClientUser extends Structures.get('User') { } module.exports = ClientUser; + +/** + * @external APIModifyClientData + * @see {@link https://discord.com/developers/docs/resources/user#modify-current-user-json-params} + */ diff --git a/src/structures/CommandInteraction.js b/src/structures/CommandInteraction.js index 0f4c6672e..2ceafc6ae 100644 --- a/src/structures/CommandInteraction.js +++ b/src/structures/CommandInteraction.js @@ -89,15 +89,15 @@ class CommandInteraction extends Interaction { * @property {Collection} [options] Additional options if this option is a * subcommand (group) * @property {User} [user] The resolved user - * @property {GuildMember|Object} [member] The resolved member - * @property {GuildChannel|Object} [channel] The resolved channel - * @property {Role|Object} [role] The resolved role + * @property {GuildMember|APIGuildMember} [member] The resolved member + * @property {GuildChannel|APIChannel} [channel] The resolved channel + * @property {Role|APIRole} [role] The resolved role */ /** * Transforms an option received from the API. - * @param {Object} option The received option - * @param {Object} resolved The resolved interaction data + * @param {APIApplicationCommandOption} option The received option + * @param {APIApplicationCommandOptionResolved} resolved The resolved interaction data * @returns {CommandInteractionOption} * @private */ @@ -127,8 +127,8 @@ class CommandInteraction extends Interaction { /** * Creates a collection of options from the received options array. - * @param {Object[]} options The received options - * @param {Object} resolved The resolved interaction data + * @param {APIApplicationCommandOption[]} options The received options + * @param {APIApplicationCommandOptionResolved} resolved The resolved interaction data * @returns {Collection} * @private */ @@ -154,3 +154,9 @@ class CommandInteraction extends Interaction { InteractionResponses.applyToClass(CommandInteraction, ['deferUpdate', 'update']); module.exports = CommandInteraction; + +/* eslint-disable max-len */ +/** + * @external APIApplicationCommandOptionResolved + * @see {@link https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataresolved} + */ diff --git a/src/structures/DMChannel.js b/src/structures/DMChannel.js index bc78c4400..31177a720 100644 --- a/src/structures/DMChannel.js +++ b/src/structures/DMChannel.js @@ -12,7 +12,7 @@ const MessageManager = require('../managers/MessageManager'); class DMChannel extends Channel { /** * @param {Client} client The instantiating client - * @param {Object} data The data for the DM channel + * @param {APIChannel} data The data for the DM channel */ constructor(client, data) { super(client, data); diff --git a/src/structures/Emoji.js b/src/structures/Emoji.js index e89faf8b0..48b2a8cdf 100644 --- a/src/structures/Emoji.js +++ b/src/structures/Emoji.js @@ -5,7 +5,7 @@ const SnowflakeUtil = require('../util/SnowflakeUtil'); /** * Represents raw emoji data from the API - * @typedef {Object} RawEmoji + * @typedef {APIEmoji} RawEmoji * @property {?Snowflake} id ID of this emoji * @property {?string} name Name of this emoji * @property {?boolean} animated Whether this emoji is animated @@ -110,3 +110,8 @@ class Emoji extends Base { } module.exports = Emoji; + +/** + * @external APIEmoji + * @see {@link https://discord.com/developers/docs/resources/emoji#emoji-object} + */ diff --git a/src/structures/Guild.js b/src/structures/Guild.js index a2e26863e..edde38f27 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -1389,3 +1389,8 @@ class Guild extends AnonymousGuild { } module.exports = Guild; + +/** + * @external APIGuild + * @see {@link https://discord.com/developers/docs/resources/guild#guild-object} + */ diff --git a/src/structures/GuildBan.js b/src/structures/GuildBan.js index f83ca496b..9a14d4de8 100644 --- a/src/structures/GuildBan.js +++ b/src/structures/GuildBan.js @@ -9,7 +9,7 @@ const Base = require('./Base'); class GuildBan extends Base { /** * @param {Client} client The instantiating client - * @param {Object} data The data for the ban + * @param {APIBanData} data The data for the ban * @param {Guild} guild The guild in which the ban is */ constructor(client, data, guild) { @@ -61,3 +61,8 @@ class GuildBan extends Base { } module.exports = GuildBan; + +/** + * @external APIBanData + * @see {@link https://discord.com/developers/docs/resources/guild#create-guild-ban-json-params} + */ diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index 92fc08726..af686f7b5 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -25,7 +25,7 @@ const Util = require('../util/Util'); class GuildChannel extends Channel { /** * @param {Guild} guild The guild the guild channel is part of - * @param {Object} data The data for the guild channel + * @param {APIChannel} data The data for the guild channel */ constructor(guild, data) { super(guild.client, data); diff --git a/src/structures/GuildEmoji.js b/src/structures/GuildEmoji.js index 43d7117a3..f26367049 100644 --- a/src/structures/GuildEmoji.js +++ b/src/structures/GuildEmoji.js @@ -12,7 +12,7 @@ const Permissions = require('../util/Permissions'); class GuildEmoji extends BaseGuildEmoji { /** * @param {Client} client The instantiating client - * @param {Object} data The data for the guild emoji + * @param {APIEmoji} data The data for the guild emoji * @param {Guild} guild The guild the guild emoji is part of */ constructor(client, data, guild) { @@ -151,7 +151,7 @@ class GuildEmoji extends BaseGuildEmoji { /** * Whether this emoji is the same as another one. - * @param {GuildEmoji|Object} other The emoji to compare it to + * @param {GuildEmoji|APIEmoji} other The emoji to compare it to * @returns {boolean} Whether the emoji is equal to the given emoji or not */ equals(other) { diff --git a/src/structures/GuildMember.js b/src/structures/GuildMember.js index f0cfb75e7..0bc84414f 100644 --- a/src/structures/GuildMember.js +++ b/src/structures/GuildMember.js @@ -15,7 +15,7 @@ let Structures; class GuildMember extends Base { /** * @param {Client} client The instantiating client - * @param {Object} data The data for the guild member + * @param {APIGuildMember} data The data for the guild member * @param {Guild} guild The guild the member is part of */ constructor(client, data, guild) { @@ -397,3 +397,8 @@ class GuildMember extends Base { TextBasedChannel.applyToClass(GuildMember); module.exports = GuildMember; + +/** + * @external APIGuildMember + * @see {@link https://discord.com/developers/docs/resources/guild#guild-member-object} + */ diff --git a/src/structures/GuildTemplate.js b/src/structures/GuildTemplate.js index d86fd6427..ed4034130 100644 --- a/src/structures/GuildTemplate.js +++ b/src/structures/GuildTemplate.js @@ -11,7 +11,7 @@ const DataResolver = require('../util/DataResolver'); class GuildTemplate extends Base { /** * @param {Client} client The instantiating client - * @param {Object} data The raw data for the template + * @param {APIGuildTemplate} data The raw data for the template */ constructor(client, data) { super(client); @@ -20,7 +20,7 @@ class GuildTemplate extends Base { /** * Builds or updates the template with the provided data. - * @param {Object} data The raw data for the template + * @param {APIGuildTemplate} data The raw data for the template * @returns {GuildTemplate} * @private */ @@ -81,8 +81,7 @@ class GuildTemplate extends Base { /** * The data of the guild that this template would create - * @type {Object} - * @see {@link https://discord.com/developers/docs/resources/guild#guild-resource} + * @type {APIGuild} */ this.serializedGuild = data.serialized_source_guild; @@ -234,3 +233,9 @@ class GuildTemplate extends Base { GuildTemplate.GUILD_TEMPLATES_PATTERN = /discord(?:app)?\.(?:com\/template|new)\/([\w-]{2,255})/gi; module.exports = GuildTemplate; + +/* eslint-disable max-len */ +/** + * @external APIGuildTemplate + * @see {@link https://discord.com/developers/docs/resources/guild-template#guild-template-object-guild-template-structure} + */ diff --git a/src/structures/Interaction.js b/src/structures/Interaction.js index 346b34785..8fb11830a 100644 --- a/src/structures/Interaction.js +++ b/src/structures/Interaction.js @@ -58,7 +58,7 @@ class Interaction extends Base { /** * If this interaction was sent in a guild, the member which sent it - * @type {?GuildMember|Object} + * @type {?GuildMember|APIGuildMember} */ this.member = data.member ? this.guild?.members.add(data.member) ?? data.member : null; diff --git a/src/structures/InteractionWebhook.js b/src/structures/InteractionWebhook.js index 68efb3970..afde7af54 100644 --- a/src/structures/InteractionWebhook.js +++ b/src/structures/InteractionWebhook.js @@ -29,7 +29,7 @@ class InteractionWebhook { /** * Sends a message with this webhook. * @param {string|APIMessage|InteractionReplyOptions} options The content for the reply - * @returns {Promise} + * @returns {Promise} */ send() {} fetchMessage() {} diff --git a/src/structures/Message.js b/src/structures/Message.js index 0b22cf211..ddb47698e 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -26,7 +26,7 @@ const Util = require('../util/Util'); class Message extends Base { /** * @param {Client} client The instantiating client - * @param {Object} data The data for the message + * @param {APIMessageRaw} data The data for the message * @param {TextChannel|DMChannel|NewsChannel} channel The channel the message was sent in */ constructor(client, data, channel) { @@ -283,7 +283,7 @@ class Message extends Base { /** * Updates the message and returns the old message. - * @param {Object} data Raw Discord message update data + * @param {APIMessageRaw} data Raw Discord message update data * @returns {Message} * @private */ @@ -537,7 +537,7 @@ class Message extends Base { * Options that can be passed into {@link Message#edit}. * @typedef {Object} MessageEditOptions * @property {?string} [content] Content to be edited - * @property {MessageEmbed[]|Object[]} [embeds] Embeds to be added/edited + * @property {MessageEmbed[]|APIEmbed[]} [embeds] Embeds to be added/edited * @property {string|boolean} [code] Language for optional codeblock formatting to apply * @property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content * @property {MessageFlags} [flags] Which flags to set for the message. Only `SUPPRESS_EMBEDS` can be edited. @@ -724,7 +724,7 @@ class Message extends Base { * without checking all the properties, use `message.id === message2.id`, which is much more efficient. This * method allows you to see if there are differences in content, embeds, attachments, nonce and tts properties. * @param {Message} message The message to compare it to - * @param {Object} rawData Raw data passed through the WebSocket about this message + * @param {APIMessageRaw} rawData Raw data passed through the WebSocket about this message * @returns {boolean} */ equals(message, rawData) { diff --git a/src/structures/MessageActionRow.js b/src/structures/MessageActionRow.js index 555b2d476..450b38778 100644 --- a/src/structures/MessageActionRow.js +++ b/src/structures/MessageActionRow.js @@ -74,7 +74,7 @@ class MessageActionRow extends BaseMessageComponent { /** * Transforms the action row to a plain object. - * @returns {Object} The raw data of this action row + * @returns {APIMessageComponent} The raw data of this action row */ toJSON() { return { @@ -85,3 +85,8 @@ class MessageActionRow extends BaseMessageComponent { } module.exports = MessageActionRow; + +/** + * @external APIMessageComponent + * @see {@link https://discord.com/developers/docs/interactions/message-components#component-object} + */ diff --git a/src/structures/MessageAttachment.js b/src/structures/MessageAttachment.js index 6041e9e76..7120c79f0 100644 --- a/src/structures/MessageAttachment.js +++ b/src/structures/MessageAttachment.js @@ -9,7 +9,7 @@ class MessageAttachment { /** * @param {BufferResolvable|Stream} attachment The file * @param {string} [name=null] The name of the file, if any - * @param {Object} [data] Extra data + * @param {APIAttachment} [data] Extra data */ constructor(attachment, name = null, data) { this.attachment = attachment; @@ -102,3 +102,8 @@ class MessageAttachment { } module.exports = MessageAttachment; + +/** + * @external APIAttachment + * @see {@link https://discord.com/developers/docs/resources/channel#attachment-object} + */ diff --git a/src/structures/MessageButton.js b/src/structures/MessageButton.js index 99ecc7de1..1cbd1246f 100644 --- a/src/structures/MessageButton.js +++ b/src/structures/MessageButton.js @@ -130,7 +130,7 @@ class MessageButton extends BaseMessageComponent { /** * Transforms the button to a plain object. - * @returns {Object} The raw data of this button + * @returns {APIMessageComponent} The raw data of this button */ toJSON() { return { diff --git a/src/structures/MessageComponentInteraction.js b/src/structures/MessageComponentInteraction.js index ffb13caab..7dece90b5 100644 --- a/src/structures/MessageComponentInteraction.js +++ b/src/structures/MessageComponentInteraction.js @@ -16,7 +16,7 @@ class MessageComponentInteraction extends Interaction { /** * The message to which the component was attached - * @type {?Message|Object} + * @type {?(Message|APIMessageRaw)} */ this.message = data.message ? this.channel?.messages.add(data.message) ?? data.message : null; diff --git a/src/structures/MessageEmbed.js b/src/structures/MessageEmbed.js index 71e482a2d..0a223b883 100644 --- a/src/structures/MessageEmbed.js +++ b/src/structures/MessageEmbed.js @@ -387,7 +387,7 @@ class MessageEmbed { /** * Transforms the embed to a plain object. - * @returns {Object} The raw data of this embed + * @returns {APIEmbed} The raw data of this embed */ toJSON() { return { @@ -457,3 +457,8 @@ class MessageEmbed { } module.exports = MessageEmbed; + +/** + * @external APIEmbed + * @see {@link https://discord.com/developers/docs/resources/channel#embed-object} + */ diff --git a/src/structures/MessageReaction.js b/src/structures/MessageReaction.js index ac0e04dc4..e59a7345d 100644 --- a/src/structures/MessageReaction.js +++ b/src/structures/MessageReaction.js @@ -11,7 +11,7 @@ const Util = require('../util/Util'); class MessageReaction { /** * @param {Client} client The instantiating client - * @param {Object} data The data for the message reaction + * @param {APIReaction} data The data for the message reaction * @param {Message} message The message the reaction refers to */ constructor(client, data, message) { @@ -134,3 +134,8 @@ class MessageReaction { } module.exports = MessageReaction; + +/** + * @external APIReaction + * @see {@link https://discord.com/developers/docs/resources/channel#reaction-object} + */ diff --git a/src/structures/PermissionOverwrites.js b/src/structures/PermissionOverwrites.js index 1e6b2b2fc..2be0ef71f 100644 --- a/src/structures/PermissionOverwrites.js +++ b/src/structures/PermissionOverwrites.js @@ -118,9 +118,7 @@ class PermissionOverwrites { /** * Resolves bitfield permissions overwrites from an object. * @param {PermissionOverwriteOptions} options The options for the update - * @param {Object} initialPermissions The initial permissions - * @param {PermissionResolvable} initialPermissions.allow Initial allowed permissions - * @param {PermissionResolvable} initialPermissions.deny Initial denied permissions + * @param {ResolvedOverwriteOptions} initialPermissions The initial permissions * @returns {ResolvedOverwriteOptions} */ static resolveOverwriteOptions(options, { allow, deny } = {}) { diff --git a/src/structures/Presence.js b/src/structures/Presence.js index c3dd423e7..8d8d24207 100644 --- a/src/structures/Presence.js +++ b/src/structures/Presence.js @@ -35,7 +35,7 @@ const Util = require('../util/Util'); class Presence { /** * @param {Client} client The instantiating client - * @param {Object} [data={}] The data for the presence + * @param {APIPresence} [data={}] The data for the presence */ constructor(client, data = {}) { /** @@ -373,3 +373,9 @@ class RichPresenceAssets { exports.Presence = Presence; exports.Activity = Activity; exports.RichPresenceAssets = RichPresenceAssets; + +/* eslint-disable max-len */ +/** + * @external APIPresence + * @see {@link https://discord.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields} + */ diff --git a/src/structures/Role.js b/src/structures/Role.js index 392faa14f..65dbdd760 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -13,7 +13,7 @@ const Util = require('../util/Util'); class Role extends Base { /** * @param {Client} client The instantiating client - * @param {Object} data The data for the role + * @param {APIRole} data The data for the role * @param {Guild} guild The guild the role is part of */ constructor(client, data, guild) { @@ -424,3 +424,8 @@ class Role extends Base { } module.exports = Role; + +/** + * @external APIRole + * @see {@link https://discord.com/developers/docs/topics/permissions#role-object} + */ diff --git a/src/structures/TextChannel.js b/src/structures/TextChannel.js index 8b519ab45..d10b4f1d5 100644 --- a/src/structures/TextChannel.js +++ b/src/structures/TextChannel.js @@ -15,7 +15,7 @@ const DataResolver = require('../util/DataResolver'); class TextChannel extends GuildChannel { /** * @param {Guild} guild The guild the text channel is part of - * @param {Object} data The data for the text channel + * @param {APIChannel} data The data for the text channel */ constructor(guild, data) { super(guild, data); diff --git a/src/structures/User.js b/src/structures/User.js index bb821b213..1deb99691 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -16,7 +16,7 @@ let Structures; class User extends Base { /** * @param {Client} client The instantiating client - * @param {Object} data The data for the user + * @param {APIUser} data The data for the user */ constructor(client, data) { super(client); @@ -333,3 +333,8 @@ class User extends Base { TextBasedChannel.applyToClass(User); module.exports = User; + +/** + * @external APIUser + * @see {@link https://discord.com/developers/docs/resources/user#user-object} + */ diff --git a/src/structures/VoiceState.js b/src/structures/VoiceState.js index 7f20d3828..96583a9ed 100644 --- a/src/structures/VoiceState.js +++ b/src/structures/VoiceState.js @@ -9,7 +9,7 @@ const { Error, TypeError } = require('../errors'); class VoiceState extends Base { /** * @param {Guild} guild The guild the voice state is part of - * @param {Object} data The data for the voice state + * @param {APIVoiceState} data The data for the voice state */ constructor(guild, data) { super(guild.client); @@ -233,3 +233,8 @@ class VoiceState extends Base { } module.exports = VoiceState; + +/** + * @external APIVoiceState + * @see {@link https://discord.com/developers/docs/resources/voice#voice-state-object} + */ diff --git a/src/structures/Webhook.js b/src/structures/Webhook.js index 26042b498..8bd354259 100644 --- a/src/structures/Webhook.js +++ b/src/structures/Webhook.js @@ -68,13 +68,13 @@ class Webhook { /** * The owner of the webhook - * @type {?User|Object} + * @type {?User|APIUser} */ this.owner = data.user ? this.client.users?.add(data.user) ?? data.user : null; /** * The source guild of the webhook - * @type {?Guild|Object} + * @type {?Guild|APIGuild} */ this.sourceGuild = data.source_guild ? this.client.guilds?.add(data.source_guild, false) ?? data.source_guild @@ -82,7 +82,7 @@ class Webhook { /** * The source channel of the webhook - * @type {?Channel|Object} + * @type {?Channel|APIChannel} */ this.sourceChannel = this.client.channels?.resolve(data.source_channel?.id) ?? data.source_channel ?? null; } @@ -97,7 +97,7 @@ class Webhook { /** * Options that can be passed into editMessage. * @typedef {Object} WebhookEditMessageOptions - * @property {MessageEmbed[]|Object[]} [embeds] See {@link WebhookMessageOptions#embeds} + * @property {MessageEmbed[]|APIEmbed[]} [embeds] See {@link WebhookMessageOptions#embeds} * @property {string} [content] See {@link BaseMessageOptions#content} * @property {FileOptions[]|BufferResolvable[]|MessageAttachment[]} [files] See {@link BaseMessageOptions#files} * @property {MessageMentionOptions} [allowedMentions] See {@link BaseMessageOptions#allowedMentions} @@ -108,7 +108,7 @@ class Webhook { /** * Sends a message with this webhook. * @param {string|APIMessage|WebhookMessageOptions} options The options to provide - * @returns {Promise} + * @returns {Promise} * @example * // Send a basic message * webhook.send('hello!') @@ -195,6 +195,7 @@ class Webhook { * 'ts': Date.now() / 1000 * }] * }).catch(console.error); + * @see {@link https://api.slack.com/messaging/webhooks} */ sendSlackMessage(body) { if (!this.token) throw new Error('WEBHOOK_TOKEN_UNAVAILABLE'); @@ -243,7 +244,7 @@ class Webhook { * Gets a message that was sent by this webhook. * @param {Snowflake|'@original'} message The ID of the message to fetch * @param {boolean} [cache=true] Whether to cache the message - * @returns {Promise} Returns the raw message data if the webhook was instantiated as a + * @returns {Promise} Returns the raw message data if the webhook was instantiated as a * {@link WebhookClient} or if the channel is uncached, otherwise a {@link Message} will be returned */ async fetchMessage(message, cache = true) { @@ -257,7 +258,7 @@ class Webhook { * Edits a message that was sent by this webhook. * @param {MessageResolvable|'@original'} message The message to edit * @param {string|APIMessage|WebhookEditMessageOptions} options The options to provide - * @returns {Promise} Returns the raw message data if the webhook was instantiated as a + * @returns {Promise} Returns the raw message data if the webhook was instantiated as a * {@link WebhookClient} or if the channel is uncached, otherwise a {@link Message} will be returned */ async editMessage(message, options) { diff --git a/src/structures/interfaces/InteractionResponses.js b/src/structures/interfaces/InteractionResponses.js index 4981b3551..3fed95fe8 100644 --- a/src/structures/interfaces/InteractionResponses.js +++ b/src/structures/interfaces/InteractionResponses.js @@ -91,7 +91,7 @@ class InteractionResponses { /** * Fetches the initial reply to this interaction. * @see Webhook#fetchMessage - * @returns {Promise} + * @returns {Promise} * @example * // Fetch the reply to this interaction * interaction.fetchReply() @@ -107,7 +107,7 @@ class InteractionResponses { * Edits the initial reply to this interaction. * @see Webhook#editMessage * @param {string|APIMessage|WebhookEditMessageOptions} options The new options for the message - * @returns {Promise} + * @returns {Promise} * @example * // Edit the reply to this interaction * interaction.editReply('New content') @@ -139,7 +139,7 @@ class InteractionResponses { /** * Send a follow-up message to this interaction. * @param {string|APIMessage|InteractionReplyOptions} options The options for the reply - * @returns {Promise} + * @returns {Promise} */ followUp(options) { return this.webhook.send(options); diff --git a/src/structures/interfaces/TextBasedChannel.js b/src/structures/interfaces/TextBasedChannel.js index 0d3a2ce8a..6cbc79849 100644 --- a/src/structures/interfaces/TextBasedChannel.js +++ b/src/structures/interfaces/TextBasedChannel.js @@ -57,7 +57,7 @@ class TextBasedChannel { * @property {boolean} [tts=false] Whether or not the message should be spoken aloud * @property {string} [nonce=''] The nonce for the message * @property {string} [content=''] The content for the message - * @property {MessageEmbed[]|Object[]} [embeds] The embeds for the message + * @property {MessageEmbed[]|APIEmbed[]} [embeds] The embeds for the message * (see [here](https://discord.com/developers/docs/resources/channel#embed-object) for more details) * @property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content * (see [here](https://discord.com/developers/docs/resources/channel#allowed-mentions-object) for more details) diff --git a/src/util/Util.js b/src/util/Util.js index 625114be2..80e93e8a7 100644 --- a/src/util/Util.js +++ b/src/util/Util.js @@ -273,7 +273,7 @@ class Util { * * A URL-encoded UTF-8 emoji (no ID) * * A Discord custom emoji (`<:name:id>` or ``) * @param {string} text Emoji string to parse - * @returns {Object} Object with `animated`, `name`, and `id` properties + * @returns {APIEmoji} Object with `animated`, `name`, and `id` properties * @private */ static parseEmoji(text) { @@ -483,7 +483,7 @@ class Util { * @param {Collection} sorted A collection of the objects sorted properly * @param {APIRouter} route Route to call PATCH on * @param {string} [reason] Reason for the change - * @returns {Promise} Updated item list, with `id` and `position` properties + * @returns {Promise} Updated item list, with `id` and `position` properties * @private */ static setPosition(item, position, relative, sorted, route, reason) {