diff --git a/packages/discord.js/src/managers/ApplicationCommandManager.js b/packages/discord.js/src/managers/ApplicationCommandManager.js index 7d08dc916d07..388b7b408fe3 100644 --- a/packages/discord.js/src/managers/ApplicationCommandManager.js +++ b/packages/discord.js/src/managers/ApplicationCommandManager.js @@ -66,12 +66,10 @@ class ApplicationCommandManager extends CachedManager { * @typedef {ApplicationCommand|Snowflake} ApplicationCommandResolvable */ - /* eslint-disable max-len */ /** * Data that resolves to the data of an ApplicationCommand - * @typedef {ApplicationCommandData|APIApplicationCommand|JSONEncodable} ApplicationCommandDataResolvable + * @typedef {ApplicationCommandData|APIApplicationCommand} ApplicationCommandDataResolvable */ - /* eslint-enable max-len */ /** * Options used to fetch data from Discord diff --git a/packages/discord.js/src/managers/GuildStickerManager.js b/packages/discord.js/src/managers/GuildStickerManager.js index c32e85f31957..a4974ecd7236 100644 --- a/packages/discord.js/src/managers/GuildStickerManager.js +++ b/packages/discord.js/src/managers/GuildStickerManager.js @@ -35,7 +35,7 @@ class GuildStickerManager extends CachedManager { /** * Options used to create a guild sticker. * @typedef {Object} GuildStickerCreateOptions - * @property {BufferResolvable|Stream|JSONEncodable} file The file for the sticker + * @property {AttachmentPayload|BufferResolvable|Stream} file The file for the sticker * @property {string} name The name for the sticker * @property {string} tags The Discord name of a unicode emoji representing the sticker's expression * @property {?string} [description] The description for the sticker diff --git a/packages/discord.js/src/managers/MessageManager.js b/packages/discord.js/src/managers/MessageManager.js index f93a54361bbe..28d622d2c79f 100644 --- a/packages/discord.js/src/managers/MessageManager.js +++ b/packages/discord.js/src/managers/MessageManager.js @@ -151,7 +151,7 @@ class MessageManager extends CachedManager { /** * Options that can be passed to edit a message. * @typedef {BaseMessageOptions} MessageEditOptions - * @property {Array>} [attachments] An array of attachments to keep, + * @property {AttachmentPayload[]} [attachments] An array of attachments to keep, * all attachments will be kept if omitted * @property {MessageFlags} [flags] Which flags to set for the message * Only the {@link MessageFlags.SuppressEmbeds} flag can be modified. diff --git a/packages/discord.js/src/structures/ActionRow.js b/packages/discord.js/src/structures/ActionRow.js index ffa2fe7ed314..3f858b7e3c0a 100644 --- a/packages/discord.js/src/structures/ActionRow.js +++ b/packages/discord.js/src/structures/ActionRow.js @@ -25,7 +25,7 @@ class ActionRow extends Component { * Creates a new action row builder from JSON data * @method from * @memberof ActionRow - * @param {JSONEncodable|APIActionRowComponent} other The other data + * @param {ActionRowBuilder|ActionRow|APIActionRowComponent} other The other data * @returns {ActionRowBuilder} * @deprecated Use {@link ActionRowBuilder.from} instead. */ diff --git a/packages/discord.js/src/structures/ActionRowBuilder.js b/packages/discord.js/src/structures/ActionRowBuilder.js index 31c30643e5bf..c3ed7d050359 100644 --- a/packages/discord.js/src/structures/ActionRowBuilder.js +++ b/packages/discord.js/src/structures/ActionRowBuilder.js @@ -18,15 +18,11 @@ class ActionRowBuilder extends BuildersActionRow { /** * Creates a new action row builder from JSON data - * @param {JSONEncodable> - * |APIActionRowComponent} other The other data + * @param {ActionRow|ActionRowBuilder|APIActionRowComponent} other The other data * @returns {ActionRowBuilder} */ static from(other) { - if (isJSONEncodable(other)) { - return new this(other.toJSON()); - } - return new this(other); + return new this(isJSONEncodable(other) ? other.toJSON() : other); } } diff --git a/packages/discord.js/src/structures/AttachmentBuilder.js b/packages/discord.js/src/structures/AttachmentBuilder.js index e2e7cf5179cd..6c638108d843 100644 --- a/packages/discord.js/src/structures/AttachmentBuilder.js +++ b/packages/discord.js/src/structures/AttachmentBuilder.js @@ -91,7 +91,7 @@ class AttachmentBuilder { /** * Makes a new builder instance from a preexisting attachment structure. - * @param {JSONEncodable} other The builder to construct a new instance from + * @param {AttachmentBuilder|Attachment|AttachmentPayload} other The builder to construct a new instance from * @returns {AttachmentBuilder} */ static from(other) { diff --git a/packages/discord.js/src/structures/ButtonBuilder.js b/packages/discord.js/src/structures/ButtonBuilder.js index 647feef519bb..34a77da2f1aa 100644 --- a/packages/discord.js/src/structures/ButtonBuilder.js +++ b/packages/discord.js/src/structures/ButtonBuilder.js @@ -27,14 +27,11 @@ class ButtonBuilder extends BuildersButton { /** * Creates a new button builder from JSON data - * @param {JSONEncodable|APIButtonComponent} other The other data + * @param {ButtonBuilder|ButtonComponent|APIButtonComponent} other The other data * @returns {ButtonBuilder} */ static from(other) { - if (isJSONEncodable(other)) { - return new this(other.toJSON()); - } - return new this(other); + return new this(isJSONEncodable(other) ? other.toJSON() : other); } } diff --git a/packages/discord.js/src/structures/ChannelSelectMenuBuilder.js b/packages/discord.js/src/structures/ChannelSelectMenuBuilder.js index 29ef31baeba2..502972372671 100644 --- a/packages/discord.js/src/structures/ChannelSelectMenuBuilder.js +++ b/packages/discord.js/src/structures/ChannelSelectMenuBuilder.js @@ -13,15 +13,12 @@ class ChannelSelectMenuBuilder extends BuildersChannelSelectMenu { } /** - * Creates a new select menu builder from json data - * @param {JSONEncodable | APISelectMenuComponent} other The other data + * Creates a new select menu builder from JSON data + * @param {ChannelSelectMenuBuilder|ChannelSelectMenuComponent|APIChannelSelectComponent} other The other data * @returns {ChannelSelectMenuBuilder} */ static from(other) { - if (isJSONEncodable(other)) { - return new this(other.toJSON()); - } - return new this(other); + return new this(isJSONEncodable(other) ? other.toJSON() : other); } } diff --git a/packages/discord.js/src/structures/EmbedBuilder.js b/packages/discord.js/src/structures/EmbedBuilder.js index 571fb6e6cc49..9259a69371ad 100644 --- a/packages/discord.js/src/structures/EmbedBuilder.js +++ b/packages/discord.js/src/structures/EmbedBuilder.js @@ -24,14 +24,11 @@ class EmbedBuilder extends BuildersEmbed { /** * Creates a new embed builder from JSON data - * @param {JSONEncodable|APIEmbed} other The other data + * @param {EmbedBuilder|Embed|APIEmbed} other The other data * @returns {EmbedBuilder} */ static from(other) { - if (isJSONEncodable(other)) { - return new this(other.toJSON()); - } - return new this(other); + return new this(isJSONEncodable(other) ? other.toJSON() : other); } } diff --git a/packages/discord.js/src/structures/MentionableSelectMenuBuilder.js b/packages/discord.js/src/structures/MentionableSelectMenuBuilder.js index 0db321923c58..2818c52ee829 100644 --- a/packages/discord.js/src/structures/MentionableSelectMenuBuilder.js +++ b/packages/discord.js/src/structures/MentionableSelectMenuBuilder.js @@ -13,15 +13,13 @@ class MentionableSelectMenuBuilder extends BuildersMentionableSelectMenu { } /** - * Creates a new select menu builder from json data - * @param {JSONEncodable | APISelectMenuComponent} other The other data + * Creates a new select menu builder from JSON data + * @param {MentionableSelectMenuBuilder|MentionableSelectMenuComponent|APIMentionableSelectComponent} other + * The other data * @returns {MentionableSelectMenuBuilder} */ static from(other) { - if (isJSONEncodable(other)) { - return new this(other.toJSON()); - } - return new this(other); + return new this(isJSONEncodable(other) ? other.toJSON() : other); } } diff --git a/packages/discord.js/src/structures/MessagePayload.js b/packages/discord.js/src/structures/MessagePayload.js index 372c1cf4b375..92d10f0d4ef1 100644 --- a/packages/discord.js/src/structures/MessagePayload.js +++ b/packages/discord.js/src/structures/MessagePayload.js @@ -227,8 +227,7 @@ class MessagePayload { /** * Resolves a single file into an object sendable to the API. - * @param {BufferResolvable|Stream|JSONEncodable} fileLike Something that could - * be resolved to a file + * @param {AttachmentPayload|BufferResolvable|Stream} fileLike Something that could be resolved to a file * @returns {Promise} */ static async resolveFile(fileLike) { diff --git a/packages/discord.js/src/structures/ModalBuilder.js b/packages/discord.js/src/structures/ModalBuilder.js index dc14012f6cc6..2db6f1a9e3a0 100644 --- a/packages/discord.js/src/structures/ModalBuilder.js +++ b/packages/discord.js/src/structures/ModalBuilder.js @@ -17,14 +17,11 @@ class ModalBuilder extends BuildersModal { /** * Creates a new modal builder from JSON data - * @param {JSONEncodable|APIModalComponent} other The other data + * @param {ModalBuilder|APIModalComponent} other The other data * @returns {ModalBuilder} */ static from(other) { - if (isJSONEncodable(other)) { - return new this(other.toJSON()); - } - return new this(other); + return new this(isJSONEncodable(other) ? other.toJSON() : other); } } diff --git a/packages/discord.js/src/structures/RoleSelectMenuBuilder.js b/packages/discord.js/src/structures/RoleSelectMenuBuilder.js index 14e5151c6b65..62219ffbc0ed 100644 --- a/packages/discord.js/src/structures/RoleSelectMenuBuilder.js +++ b/packages/discord.js/src/structures/RoleSelectMenuBuilder.js @@ -13,15 +13,12 @@ class RoleSelectMenuBuilder extends BuildersRoleSelectMenu { } /** - * Creates a new select menu builder from json data - * @param {JSONEncodable | APISelectMenuComponent} other The other data + * Creates a new select menu builder from JSON data + * @param {RoleSelectMenuBuilder|RoleSelectMenuComponent|APIRoleSelectComponent} other The other data * @returns {RoleSelectMenuBuilder} */ static from(other) { - if (isJSONEncodable(other)) { - return new this(other.toJSON()); - } - return new this(other); + return new this(isJSONEncodable(other) ? other.toJSON() : other); } } diff --git a/packages/discord.js/src/structures/StringSelectMenuBuilder.js b/packages/discord.js/src/structures/StringSelectMenuBuilder.js index 7eccb39b191c..537c54126513 100644 --- a/packages/discord.js/src/structures/StringSelectMenuBuilder.js +++ b/packages/discord.js/src/structures/StringSelectMenuBuilder.js @@ -23,7 +23,7 @@ class StringSelectMenuBuilder extends BuildersSelectMenu { /** * Normalizes a select menu option emoji - * @param {SelectMenuOptionData|JSONEncodable} selectMenuOption The option to normalize + * @param {SelectMenuOptionData|APISelectMenuOption} selectMenuOption The option to normalize * @returns {SelectMenuOptionBuilder|APISelectMenuOption} * @private */ @@ -59,7 +59,7 @@ class StringSelectMenuBuilder extends BuildersSelectMenu { /** * Creates a new select menu builder from json data - * @param {JSONEncodable | APISelectMenuComponent} other The other data + * @param {StringSelectMenuBuilder|StringSelectMenuComponent|APIStringSelectComponent} other The other data * @returns {StringSelectMenuBuilder} */ static from(other) { diff --git a/packages/discord.js/src/structures/StringSelectMenuOptionBuilder.js b/packages/discord.js/src/structures/StringSelectMenuOptionBuilder.js index 8e1cad8c2e1f..7097fb5929b6 100644 --- a/packages/discord.js/src/structures/StringSelectMenuOptionBuilder.js +++ b/packages/discord.js/src/structures/StringSelectMenuOptionBuilder.js @@ -32,14 +32,11 @@ class StringSelectMenuOptionBuilder extends BuildersSelectMenuOption { /** * Creates a new select menu option builder from JSON data - * @param {JSONEncodable|APISelectMenuOption} other The other data + * @param {StringSelectMenuOptionBuilder|APISelectMenuOption} other The other data * @returns {StringSelectMenuOptionBuilder} */ static from(other) { - if (isJSONEncodable(other)) { - return new this(other.toJSON()); - } - return new this(other); + return new this(isJSONEncodable(other) ? other.toJSON() : other); } } diff --git a/packages/discord.js/src/structures/TextInputBuilder.js b/packages/discord.js/src/structures/TextInputBuilder.js index 4d07735cb868..9c044d738289 100644 --- a/packages/discord.js/src/structures/TextInputBuilder.js +++ b/packages/discord.js/src/structures/TextInputBuilder.js @@ -14,14 +14,11 @@ class TextInputBuilder extends BuildersTextInput { /** * Creates a new text input builder from JSON data - * @param {JSONEncodable|APITextInputComponent} other The other data + * @param {TextInputBuilder|TextInputComponent|APITextInputComponent} other The other data * @returns {TextInputBuilder} */ static from(other) { - if (isJSONEncodable(other)) { - return new this(other.toJSON()); - } - return new this(other); + return new this(isJSONEncodable(other) ? other.toJSON() : other); } } diff --git a/packages/discord.js/src/structures/UserSelectMenuBuilder.js b/packages/discord.js/src/structures/UserSelectMenuBuilder.js index fab93f6b9f97..7ca105c425eb 100644 --- a/packages/discord.js/src/structures/UserSelectMenuBuilder.js +++ b/packages/discord.js/src/structures/UserSelectMenuBuilder.js @@ -13,15 +13,12 @@ class UserSelectMenuBuilder extends BuildersUserSelectMenu { } /** - * Creates a new select menu builder from json data - * @param {JSONEncodable | APISelectMenuComponent} other The other data + * Creates a new select menu builder from JSON data + * @param {UserSelectMenuBuilder|UserSelectMenuComponent|APIUserSelectComponent} other The other data * @returns {UserSelectMenuBuilder} */ static from(other) { - if (isJSONEncodable(other)) { - return new this(other.toJSON()); - } - return new this(other); + return new this(isJSONEncodable(other) ? other.toJSON() : other); } } diff --git a/packages/discord.js/src/structures/interfaces/TextBasedChannel.js b/packages/discord.js/src/structures/interfaces/TextBasedChannel.js index d8562f81a433..d5f9b27f2472 100644 --- a/packages/discord.js/src/structures/interfaces/TextBasedChannel.js +++ b/packages/discord.js/src/structures/interfaces/TextBasedChannel.js @@ -59,7 +59,7 @@ class TextBasedChannel { * @property {Embed[]|APIEmbed[]} [embeds] The embeds for the message * @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) - * @property {Array>|BufferResolvable[]|Attachment[]|AttachmentBuilder[]} [files] + * @property {AttachmentBuilder[]|Attachment[]|AttachmentPayload[]|BufferResolvable[]} [files] * The files to send with the message. * @property {ActionRow[]|ActionRowBuilder[]} [components] * Action rows containing interactive components for the message (buttons, select menus) diff --git a/packages/discord.js/src/util/APITypes.js b/packages/discord.js/src/util/APITypes.js index 79e48febcbe8..3a4878e2d4d9 100644 --- a/packages/discord.js/src/util/APITypes.js +++ b/packages/discord.js/src/util/APITypes.js @@ -43,6 +43,11 @@ * @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIChannel} */ +/** + * @external APIChannelSelectComponent + * @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIChannelSelectComponent} + */ + /** * @external APIEmbed * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIEmbed} @@ -98,6 +103,11 @@ * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIInteractionGuildMember} */ +/** + * @external APIMentionableSelectComponent + * @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIMentionableSelectComponent} + */ + /** * @external APIMessage * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIMessage} @@ -139,13 +149,13 @@ */ /** - * @external APISelectMenuComponent - * @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APISelectMenuComponent} + * @external APISelectMenuOption + * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APISelectMenuOption} */ /** - * @external APISelectMenuOption - * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APISelectMenuOption} + * @external APIStringSelectComponent + * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIStringSelectComponent} */ /** diff --git a/packages/discord.js/src/util/Components.js b/packages/discord.js/src/util/Components.js index 4369c8cdeddc..1a2ccbcd24ad 100644 --- a/packages/discord.js/src/util/Components.js +++ b/packages/discord.js/src/util/Components.js @@ -150,8 +150,3 @@ const TextInputBuilder = require('../structures/TextInputBuilder'); const TextInputComponent = require('../structures/TextInputComponent'); const UserSelectMenuBuilder = require('../structures/UserSelectMenuBuilder'); const UserSelectMenuComponent = require('../structures/UserSelectMenuComponent'); - -/** - * @external JSONEncodable - * @see {@link https://discord.js.org/docs/packages/util/main/JSONEncodable:Interface} - */