From 12e510671b67c11e1a659d344bb3f4c939e2d44c Mon Sep 17 00:00:00 2001 From: Denis Cristea Date: Fri, 4 Oct 2024 14:17:34 +0300 Subject: [PATCH] chore!: remove all deprecated features/props (#10421) BREAKING CHANGE: Removed `Client#fetchPremiumStickerPacks` method BREAKING CHANGE: Removed `Client#webhookUpdate` event BREAKING CHANGE: Removed various error codes BREAKING CHANGE: Removed `Formatters` namespace BREAKING CHANGE: Removed `InviteStageInstance` class BREAKING CHANGE: Removed `Invite#stageInstance` property BREAKING CHANGE: Removed `StageInstance#discoverable_disabled` property BREAKING CHANGE: Removed `SelectMenuBuilder` alias BREAKING CHANGE: Removed `SelectMenuComponent` alias BREAKING CHANGE: Removed `SelectMenuInteraction` alias BREAKING CHANGE: Removed `SelectMenuOptionBuilder` alias BREAKING CHANGE: Removed `BaseInteraction#isSelectMenu` alias BREAKING CHANGE: Removed `deleteMessageDays` option from `GuildBanManager#create` BREAKING CHANGE: Removed `ActionRow#from` method BREAKING CHANGE: Removed `Emoji#url` getter BREAKING CHANGE: Removed `TeamMember#permissions` property BREAKING CHANGE: Removed `User#avatarDecoration` property BREAKING CHANGE: Removed `InteractionResponses#sendPremiumRequired` method BREAKING CHANGE: Removed `DeletableMessageTypes` constant --- packages/discord.js/src/client/Client.js | 20 - .../src/client/actions/WebhooksUpdate.js | 19 +- packages/discord.js/src/errors/ErrorCodes.js | 85 +--- packages/discord.js/src/errors/Messages.js | 30 -- packages/discord.js/src/index.js | 6 - .../src/managers/GuildBanManager.js | 29 +- .../src/managers/GuildMemberManager.js | 2 +- .../discord.js/src/managers/RoleManager.js | 16 +- .../discord.js/src/structures/ActionRow.js | 15 - .../src/structures/BaseGuildEmoji.js | 10 - .../src/structures/BaseInteraction.js | 15 - .../src/structures/CommandInteraction.js | 1 - packages/discord.js/src/structures/Emoji.js | 18 - packages/discord.js/src/structures/Invite.js | 12 - .../src/structures/InviteStageInstance.js | 87 ---- .../structures/MessageComponentInteraction.js | 1 - .../src/structures/ModalSubmitInteraction.js | 1 - .../src/structures/SelectMenuBuilder.js | 26 -- .../src/structures/SelectMenuComponent.js | 26 -- .../src/structures/SelectMenuInteraction.js | 26 -- .../src/structures/SelectMenuOptionBuilder.js | 26 -- .../src/structures/StageInstance.js | 11 - .../src/structures/StringSelectMenuBuilder.js | 4 +- .../discord.js/src/structures/TeamMember.js | 9 - .../src/structures/ThreadChannel.js | 13 +- packages/discord.js/src/structures/User.js | 22 +- .../interfaces/InteractionResponses.js | 25 -- packages/discord.js/src/util/Constants.js | 50 --- packages/discord.js/src/util/Events.js | 4 +- packages/discord.js/src/util/Formatters.js | 413 ------------------ packages/discord.js/test/monetization.js | 14 +- packages/discord.js/test/tester2000.js | 4 +- packages/discord.js/typings/index.d.ts | 203 +-------- packages/discord.js/typings/index.test-d.ts | 27 +- packages/discord.js/typings/rawDataTypes.d.ts | 3 - 35 files changed, 45 insertions(+), 1228 deletions(-) delete mode 100644 packages/discord.js/src/structures/InviteStageInstance.js delete mode 100644 packages/discord.js/src/structures/SelectMenuBuilder.js delete mode 100644 packages/discord.js/src/structures/SelectMenuComponent.js delete mode 100644 packages/discord.js/src/structures/SelectMenuInteraction.js delete mode 100644 packages/discord.js/src/structures/SelectMenuOptionBuilder.js delete mode 100644 packages/discord.js/src/util/Formatters.js diff --git a/packages/discord.js/src/client/Client.js b/packages/discord.js/src/client/Client.js index 1d378a4dcd3d..3a72b8414986 100644 --- a/packages/discord.js/src/client/Client.js +++ b/packages/discord.js/src/client/Client.js @@ -31,8 +31,6 @@ const PermissionsBitField = require('../util/PermissionsBitField'); const Status = require('../util/Status'); const Sweepers = require('../util/Sweepers'); -let deprecationEmittedForPremiumStickerPacks = false; - /** * The main hub for interacting with the Discord API, and the starting point for any bot. * @extends {BaseClient} @@ -372,24 +370,6 @@ class Client extends BaseClient { return new Collection(data.sticker_packs.map(stickerPack => [stickerPack.id, new StickerPack(this, stickerPack)])); } - /** - * Obtains the list of available sticker packs. - * @returns {Promise>} - * @deprecated Use {@link Client#fetchStickerPacks} instead. - */ - fetchPremiumStickerPacks() { - if (!deprecationEmittedForPremiumStickerPacks) { - process.emitWarning( - 'The Client#fetchPremiumStickerPacks() method is deprecated. Use Client#fetchStickerPacks() instead.', - 'DeprecationWarning', - ); - - deprecationEmittedForPremiumStickerPacks = true; - } - - return this.fetchStickerPacks(); - } - /** * Obtains a guild preview from Discord, available for all guilds the bot is in and all Discoverable guilds. * @param {GuildResolvable} guild The guild to fetch the preview for diff --git a/packages/discord.js/src/client/actions/WebhooksUpdate.js b/packages/discord.js/src/client/actions/WebhooksUpdate.js index 2f0394c19186..3e3c46affc3e 100644 --- a/packages/discord.js/src/client/actions/WebhooksUpdate.js +++ b/packages/discord.js/src/client/actions/WebhooksUpdate.js @@ -1,9 +1,7 @@ 'use strict'; -const process = require('node:process'); const Action = require('./Action'); - -let deprecationEmitted = false; +const Events = require('../../util/Events'); class WebhooksUpdate extends Action { handle(data) { @@ -11,26 +9,13 @@ class WebhooksUpdate extends Action { const channel = client.channels.cache.get(data.channel_id); if (!channel) return; - // TODO: change to Events.WebhooksUpdate in the next major version /** * Emitted whenever a channel has its webhooks changed. * @event Client#webhooksUpdate * @param {TextChannel|NewsChannel|VoiceChannel|StageChannel|ForumChannel|MediaChannel} channel * The channel that had a webhook update */ - client.emit('webhooksUpdate', channel); - - /** - * Emitted whenever a channel has its webhooks changed. - * @event Client#webhookUpdate - * @param {TextChannel|NewsChannel|VoiceChannel|StageChannel|ForumChannel|MediaChannel} channel - * The channel that had a webhook update - * @deprecated Use {@link Client#event:webhooksUpdate} instead. - */ - if (client.emit('webhookUpdate', channel) && !deprecationEmitted) { - deprecationEmitted = true; - process.emitWarning('The webhookUpdate event is deprecated. Use webhooksUpdate instead.', 'DeprecationWarning'); - } + client.emit(Events.WebhooksUpdate, channel); } } diff --git a/packages/discord.js/src/errors/ErrorCodes.js b/packages/discord.js/src/errors/ErrorCodes.js index c1552392aa90..7d7b0b99ec1b 100644 --- a/packages/discord.js/src/errors/ErrorCodes.js +++ b/packages/discord.js/src/errors/ErrorCodes.js @@ -12,25 +12,8 @@ * @property {'TokenMissing'} TokenMissing * @property {'ApplicationCommandPermissionsTokenMissing'} ApplicationCommandPermissionsTokenMissing - * @property {'WSCloseRequested'} WSCloseRequested - * This property is deprecated. - * @property {'WSConnectionExists'} WSConnectionExists - * This property is deprecated. - * @property {'WSNotOpen'} WSNotOpen - * This property is deprecated. - * @property {'ManagerDestroyed'} ManagerDestroyed - * This property is deprecated. - - * @property {'BitFieldInvalid'} BitFieldInvalid - - * @property {'ShardingInvalid'} ShardingInvalid - * This property is deprecated. - * @property {'ShardingRequired'} ShardingRequired - * This property is deprecated. - * @property {'InvalidIntents'} InvalidIntents - * This property is deprecated. - * @property {'DisallowedIntents'} DisallowedIntents - * This property is deprecated. +* @property {'BitFieldInvalid'} BitFieldInvalid + * @property {'ShardingNoShards'} ShardingNoShards * @property {'ShardingInProcess'} ShardingInProcess * @property {'ShardingInvalidEvalBroadcast'} ShardingInvalidEvalBroadcast @@ -49,30 +32,10 @@ * @property {'InviteOptionsMissingChannel'} InviteOptionsMissingChannel - * @property {'ButtonLabel'} ButtonLabel - * This property is deprecated. - * @property {'ButtonURL'} ButtonURL - * This property is deprecated. - * @property {'ButtonCustomId'} ButtonCustomId - * This property is deprecated. - - * @property {'SelectMenuCustomId'} SelectMenuCustomId - * This property is deprecated. - * @property {'SelectMenuPlaceholder'} SelectMenuPlaceholder - * This property is deprecated. - * @property {'SelectOptionLabel'} SelectOptionLabel - * This property is deprecated. - * @property {'SelectOptionValue'} SelectOptionValue - * This property is deprecated. - * @property {'SelectOptionDescription'} SelectOptionDescription - * This property is deprecated. - * @property {'InteractionCollectorError'} InteractionCollectorError * @property {'FileNotFound'} FileNotFound - * @property {'UserBannerNotFetched'} UserBannerNotFetched - * This property is deprecated. * @property {'UserNoDMChannel'} UserNoDMChannel * @property {'VoiceNotStageChannel'} VoiceNotStageChannel @@ -82,19 +45,11 @@ * @property {'ReqResourceType'} ReqResourceType - * @property {'ImageFormat'} ImageFormat - * This property is deprecated. - * @property {'ImageSize'} ImageSize - * This property is deprecated. - * @property {'MessageBulkDeleteType'} MessageBulkDeleteType * @property {'MessageContentType'} MessageContentType * @property {'MessageNonceRequired'} MessageNonceRequired * @property {'MessageNonceType'} MessageNonceType - * @property {'SplitMaxLen'} SplitMaxLen - * This property is deprecated. - * @property {'BanResolveId'} BanResolveId * @property {'FetchBanResolveId'} FetchBanResolveId @@ -128,16 +83,11 @@ * @property {'EmojiType'} EmojiType * @property {'EmojiManaged'} EmojiManaged * @property {'MissingManageGuildExpressionsPermission'} MissingManageGuildExpressionsPermission - * @property {'MissingManageEmojisAndStickersPermission'} MissingManageEmojisAndStickersPermission - * This property is deprecated. Use `MissingManageGuildExpressionsPermission` instead. * * @property {'NotGuildSticker'} NotGuildSticker * @property {'ReactionResolveUser'} ReactionResolveUser - * @property {'VanityURL'} VanityURL - * This property is deprecated. - * @property {'InviteResolveCode'} InviteResolveCode * @property {'InviteNotFound'} InviteNotFound @@ -152,8 +102,6 @@ * @property {'InteractionAlreadyReplied'} InteractionAlreadyReplied * @property {'InteractionNotReplied'} InteractionNotReplied - * @property {'InteractionEphemeralReplied'} InteractionEphemeralReplied - * This property is deprecated. * @property {'CommandInteractionOptionNotFound'} CommandInteractionOptionNotFound * @property {'CommandInteractionOptionType'} CommandInteractionOptionType @@ -192,17 +140,8 @@ const keys = [ 'TokenMissing', 'ApplicationCommandPermissionsTokenMissing', - 'WSCloseRequested', - 'WSConnectionExists', - 'WSNotOpen', - 'ManagerDestroyed', - 'BitFieldInvalid', - 'ShardingInvalid', - 'ShardingRequired', - 'InvalidIntents', - 'DisallowedIntents', 'ShardingNoShards', 'ShardingInProcess', 'ShardingInvalidEvalBroadcast', @@ -221,21 +160,10 @@ const keys = [ 'InviteOptionsMissingChannel', - 'ButtonLabel', - 'ButtonURL', - 'ButtonCustomId', - - 'SelectMenuCustomId', - 'SelectMenuPlaceholder', - 'SelectOptionLabel', - 'SelectOptionValue', - 'SelectOptionDescription', - 'InteractionCollectorError', 'FileNotFound', - 'UserBannerNotFetched', 'UserNoDMChannel', 'VoiceNotStageChannel', @@ -245,16 +173,11 @@ const keys = [ 'ReqResourceType', - 'ImageFormat', - 'ImageSize', - 'MessageBulkDeleteType', 'MessageContentType', 'MessageNonceRequired', 'MessageNonceType', - 'SplitMaxLen', - 'BanResolveId', 'FetchBanResolveId', @@ -288,14 +211,11 @@ const keys = [ 'EmojiType', 'EmojiManaged', 'MissingManageGuildExpressionsPermission', - 'MissingManageEmojisAndStickersPermission', 'NotGuildSticker', 'ReactionResolveUser', - 'VanityURL', - 'InviteResolveCode', 'InviteNotFound', @@ -310,7 +230,6 @@ const keys = [ 'InteractionAlreadyReplied', 'InteractionNotReplied', - 'InteractionEphemeralReplied', 'CommandInteractionOptionNotFound', 'CommandInteractionOptionType', diff --git a/packages/discord.js/src/errors/Messages.js b/packages/discord.js/src/errors/Messages.js index 234718c50c79..41e81dd3402f 100644 --- a/packages/discord.js/src/errors/Messages.js +++ b/packages/discord.js/src/errors/Messages.js @@ -13,17 +13,8 @@ const Messages = { [DjsErrorCodes.ApplicationCommandPermissionsTokenMissing]: 'Editing application command permissions requires an OAuth2 bearer token, but none was provided.', - [DjsErrorCodes.WSCloseRequested]: 'WebSocket closed due to user request.', - [DjsErrorCodes.WSConnectionExists]: 'There is already an existing WebSocket connection.', - [DjsErrorCodes.WSNotOpen]: (data = 'data') => `WebSocket not open to send ${data}`, - [DjsErrorCodes.ManagerDestroyed]: 'Manager was destroyed.', - [DjsErrorCodes.BitFieldInvalid]: bit => `Invalid bitfield flag or number: ${bit}.`, - [DjsErrorCodes.ShardingInvalid]: 'Invalid shard settings were provided.', - [DjsErrorCodes.ShardingRequired]: 'This session would have handled too many guilds - Sharding is required.', - [DjsErrorCodes.InvalidIntents]: 'Invalid intent provided for WebSocket intents.', - [DjsErrorCodes.DisallowedIntents]: 'Privileged intent provided is not enabled or whitelisted.', [DjsErrorCodes.ShardingNoShards]: 'No shards have been spawned.', [DjsErrorCodes.ShardingInProcess]: 'Shards are still being spawned.', [DjsErrorCodes.ShardingInvalidEvalBroadcast]: 'Script to evaluate must be a function', @@ -44,22 +35,11 @@ const Messages = { [DjsErrorCodes.InviteOptionsMissingChannel]: 'A valid guild channel must be provided when GuildScheduledEvent is EXTERNAL.', - [DjsErrorCodes.ButtonLabel]: 'MessageButton label must be a string', - [DjsErrorCodes.ButtonURL]: 'MessageButton URL must be a string', - [DjsErrorCodes.ButtonCustomId]: 'MessageButton customId must be a string', - - [DjsErrorCodes.SelectMenuCustomId]: 'MessageSelectMenu customId must be a string', - [DjsErrorCodes.SelectMenuPlaceholder]: 'MessageSelectMenu placeholder must be a string', - [DjsErrorCodes.SelectOptionLabel]: 'MessageSelectOption label must be a string', - [DjsErrorCodes.SelectOptionValue]: 'MessageSelectOption value must be a string', - [DjsErrorCodes.SelectOptionDescription]: 'MessageSelectOption description must be a string', - [DjsErrorCodes.InteractionCollectorError]: reason => `Collector received no interactions before ending with reason: ${reason}`, [DjsErrorCodes.FileNotFound]: file => `File could not be found: ${file}`, - [DjsErrorCodes.UserBannerNotFetched]: "You must fetch this user's banner before trying to generate its URL!", [DjsErrorCodes.UserNoDMChannel]: 'No DM Channel exists!', [DjsErrorCodes.VoiceNotStageChannel]: 'You are only allowed to do this in stage channels.', @@ -70,16 +50,11 @@ const Messages = { [DjsErrorCodes.ReqResourceType]: 'The resource must be a string, Buffer or a valid file stream.', - [DjsErrorCodes.ImageFormat]: format => `Invalid image format: ${format}`, - [DjsErrorCodes.ImageSize]: size => `Invalid image size: ${size}`, - [DjsErrorCodes.MessageBulkDeleteType]: 'The messages must be an Array, Collection, or number.', [DjsErrorCodes.MessageContentType]: 'Message content must be a string.', [DjsErrorCodes.MessageNonceRequired]: 'Message nonce is required when enforceNonce is true.', [DjsErrorCodes.MessageNonceType]: 'Message nonce must be an integer or a string.', - [DjsErrorCodes.SplitMaxLen]: 'Chunk exceeds the max length and contains no split characters.', - [DjsErrorCodes.BanResolveId]: (ban = false) => `Couldn't resolve the user id to ${ban ? 'ban' : 'unban'}.`, [DjsErrorCodes.FetchBanResolveId]: "Couldn't resolve the user id to fetch the ban.", @@ -114,15 +89,11 @@ const Messages = { [DjsErrorCodes.EmojiManaged]: 'Emoji is managed and has no Author.', [DjsErrorCodes.MissingManageGuildExpressionsPermission]: guild => `Client must have Manage Guild Expressions permission in guild ${guild} to see emoji authors.`, - [DjsErrorCodes.MissingManageEmojisAndStickersPermission]: guild => - `Client must have Manage Emojis and Stickers permission in guild ${guild} to see emoji authors.`, [DjsErrorCodes.NotGuildSticker]: 'Sticker is a standard (non-guild) sticker and has no author.', [DjsErrorCodes.ReactionResolveUser]: "Couldn't resolve the user id to remove from the reaction.", - [DjsErrorCodes.VanityURL]: 'This guild does not have the vanity URL feature enabled.', - [DjsErrorCodes.InviteResolveCode]: 'Could not resolve the code to fetch the invite.', [DjsErrorCodes.InviteNotFound]: 'Could not find the requested invite.', @@ -140,7 +111,6 @@ const Messages = { [DjsErrorCodes.InteractionAlreadyReplied]: 'The reply to this interaction has already been sent or deferred.', [DjsErrorCodes.InteractionNotReplied]: 'The reply to this interaction has not been sent or deferred.', - [DjsErrorCodes.InteractionEphemeralReplied]: 'Ephemeral responses cannot be deleted.', [DjsErrorCodes.CommandInteractionOptionNotFound]: name => `Required option "${name}" not found.`, [DjsErrorCodes.CommandInteractionOptionType]: (name, type, expected) => diff --git a/packages/discord.js/src/index.js b/packages/discord.js/src/index.js index 5b30a29bcdd6..45e8ac4f797c 100644 --- a/packages/discord.js/src/index.js +++ b/packages/discord.js/src/index.js @@ -31,7 +31,6 @@ exports.Constants = require('./util/Constants'); exports.Colors = require('./util/Colors'); __exportStar(require('./util/DataResolver.js'), exports); exports.Events = require('./util/Events'); -exports.Formatters = require('./util/Formatters'); exports.GuildMemberFlagsBitField = require('./util/GuildMemberFlagsBitField').GuildMemberFlagsBitField; exports.IntentsBitField = require('./util/IntentsBitField'); exports.LimitedCollection = require('./util/LimitedCollection'); @@ -151,7 +150,6 @@ exports.InteractionCollector = require('./structures/InteractionCollector'); exports.InteractionResponse = require('./structures/InteractionResponse'); exports.InteractionWebhook = require('./structures/InteractionWebhook'); exports.Invite = require('./structures/Invite'); -exports.InviteStageInstance = require('./structures/InviteStageInstance'); exports.InviteGuild = require('./structures/InviteGuild'); exports.Message = require('./structures/Message').Message; exports.Attachment = require('./structures/Attachment'); @@ -177,27 +175,23 @@ exports.ReactionCollector = require('./structures/ReactionCollector'); exports.ReactionEmoji = require('./structures/ReactionEmoji'); exports.RichPresenceAssets = require('./structures/Presence').RichPresenceAssets; exports.Role = require('./structures/Role').Role; -exports.SelectMenuBuilder = require('./structures/SelectMenuBuilder'); exports.ChannelSelectMenuBuilder = require('./structures/ChannelSelectMenuBuilder'); exports.MentionableSelectMenuBuilder = require('./structures/MentionableSelectMenuBuilder'); exports.RoleSelectMenuBuilder = require('./structures/RoleSelectMenuBuilder'); exports.StringSelectMenuBuilder = require('./structures/StringSelectMenuBuilder'); exports.UserSelectMenuBuilder = require('./structures/UserSelectMenuBuilder'); exports.BaseSelectMenuComponent = require('./structures/BaseSelectMenuComponent'); -exports.SelectMenuComponent = require('./structures/SelectMenuComponent'); exports.ChannelSelectMenuComponent = require('./structures/ChannelSelectMenuComponent'); exports.MentionableSelectMenuComponent = require('./structures/MentionableSelectMenuComponent'); exports.RoleSelectMenuComponent = require('./structures/RoleSelectMenuComponent'); exports.StringSelectMenuComponent = require('./structures/StringSelectMenuComponent'); exports.UserSelectMenuComponent = require('./structures/UserSelectMenuComponent'); -exports.SelectMenuInteraction = require('./structures/SelectMenuInteraction'); exports.ChannelSelectMenuInteraction = require('./structures/ChannelSelectMenuInteraction'); exports.MentionableSelectMenuInteraction = require('./structures/MentionableSelectMenuInteraction'); exports.MentionableSelectMenuInteraction = require('./structures/MentionableSelectMenuInteraction'); exports.RoleSelectMenuInteraction = require('./structures/RoleSelectMenuInteraction'); exports.StringSelectMenuInteraction = require('./structures/StringSelectMenuInteraction'); exports.UserSelectMenuInteraction = require('./structures/UserSelectMenuInteraction'); -exports.SelectMenuOptionBuilder = require('./structures/SelectMenuOptionBuilder'); exports.SKU = require('./structures/SKU').SKU; exports.StringSelectMenuOptionBuilder = require('./structures/StringSelectMenuOptionBuilder'); exports.StageChannel = require('./structures/StageChannel'); diff --git a/packages/discord.js/src/managers/GuildBanManager.js b/packages/discord.js/src/managers/GuildBanManager.js index 5bcbd368fb0c..53f5ca38f391 100644 --- a/packages/discord.js/src/managers/GuildBanManager.js +++ b/packages/discord.js/src/managers/GuildBanManager.js @@ -1,6 +1,5 @@ 'use strict'; -const process = require('node:process'); const { Collection } = require('@discordjs/collection'); const { makeURLSearchParams } = require('@discordjs/rest'); const { Routes } = require('discord-api-types/v10'); @@ -9,8 +8,6 @@ const { DiscordjsTypeError, DiscordjsError, ErrorCodes } = require('../errors'); const GuildBan = require('../structures/GuildBan'); const { GuildMember } = require('../structures/GuildMember'); -let deprecationEmittedForDeleteMessageDays = false; - /** * Manages API methods for guild bans and stores their cache. * @extends {CachedManager} @@ -131,8 +128,6 @@ class GuildBanManager extends CachedManager { /** * Options used to ban a user from a guild. * @typedef {Object} BanOptions - * @property {number} [deleteMessageDays] Number of days of messages to delete, must be between 0 and 7, inclusive - * This property is deprecated. Use `deleteMessageSeconds` instead. * @property {number} [deleteMessageSeconds] Number of seconds of messages to delete, * must be between 0 and 604800 (7 days), inclusive * @property {string} [reason] The reason for the ban @@ -156,21 +151,9 @@ class GuildBanManager extends CachedManager { const id = this.client.users.resolveId(user); if (!id) throw new DiscordjsError(ErrorCodes.BanResolveId, true); - if (options.deleteMessageDays !== undefined && !deprecationEmittedForDeleteMessageDays) { - process.emitWarning( - // eslint-disable-next-line max-len - 'The deleteMessageDays option for GuildBanManager#create() is deprecated. Use the deleteMessageSeconds option instead.', - 'DeprecationWarning', - ); - - deprecationEmittedForDeleteMessageDays = true; - } - await this.client.rest.put(Routes.guildBan(this.guild.id, id), { body: { - delete_message_seconds: - options.deleteMessageSeconds ?? - (options.deleteMessageDays ? options.deleteMessageDays * 24 * 60 * 60 : undefined), + delete_message_seconds: options.deleteMessageSeconds, }, reason: options.reason, }); @@ -200,14 +183,6 @@ class GuildBanManager extends CachedManager { return this.client.users.resolve(user); } - /** - * Options used for bulk banning users from a guild. - * @typedef {Object} BulkBanOptions - * @property {number} [deleteMessageSeconds] Number of seconds of messages to delete, - * must be between 0 and 604800 (7 days), inclusive - * @property {string} [reason] The reason for the bans - */ - /** * Result of bulk banning users from a guild. * @typedef {Object} BulkBanResult @@ -218,7 +193,7 @@ class GuildBanManager extends CachedManager { /** * Bulk ban users from a guild, and optionally delete previous messages sent by them. * @param {Collection|UserResolvable[]} users The users to ban - * @param {BulkBanOptions} [options] The options for bulk banning users + * @param {BanOptions} [options] The options for bulk banning users * @returns {Promise} Returns an object with `bannedUsers` key containing the IDs of the banned users * and the key `failedUsers` with the IDs that could not be banned or were already banned. * @example diff --git a/packages/discord.js/src/managers/GuildMemberManager.js b/packages/discord.js/src/managers/GuildMemberManager.js index 909ac6213169..4b1b48e62d1d 100644 --- a/packages/discord.js/src/managers/GuildMemberManager.js +++ b/packages/discord.js/src/managers/GuildMemberManager.js @@ -504,7 +504,7 @@ class GuildMemberManager extends CachedManager { /** * Bulk ban users from a guild, and optionally delete previous messages sent by them. * @param {Collection|UserResolvable[]} users The users to ban - * @param {BulkBanOptions} [options] The options for bulk banning users + * @param {BanOptions} [options] The options for bulk banning users * @returns {Promise} Returns an object with `bannedUsers` key containing the IDs of the banned users * and the key `failedUsers` with the IDs that could not be banned or were already banned. * Internally calls the GuildBanManager#bulkCreate method. diff --git a/packages/discord.js/src/managers/RoleManager.js b/packages/discord.js/src/managers/RoleManager.js index a69018f54329..f1b2d29388c6 100644 --- a/packages/discord.js/src/managers/RoleManager.js +++ b/packages/discord.js/src/managers/RoleManager.js @@ -2,8 +2,7 @@ const process = require('node:process'); const { Collection } = require('@discordjs/collection'); -const { DiscordAPIError } = require('@discordjs/rest'); -const { RESTJSONErrorCodes, Routes } = require('discord-api-types/v10'); +const { Routes } = require('discord-api-types/v10'); const CachedManager = require('./CachedManager'); const { DiscordjsTypeError, ErrorCodes } = require('../errors'); const { Role } = require('../structures/Role'); @@ -74,17 +73,8 @@ class RoleManager extends CachedManager { if (existing) return existing; } - try { - const data = await this.client.rest.get(Routes.guildRole(this.guild.id, id)); - return this._add(data, cache); - } catch (error) { - // TODO: Remove this catch in the next major version - if (error instanceof DiscordAPIError && error.code === RESTJSONErrorCodes.UnknownRole) { - return null; - } - - throw error; - } + const data = await this.client.rest.get(Routes.guildRole(this.guild.id, id)); + return this._add(data, cache); } /** diff --git a/packages/discord.js/src/structures/ActionRow.js b/packages/discord.js/src/structures/ActionRow.js index 041224ee0c49..ad9a59e2c848 100644 --- a/packages/discord.js/src/structures/ActionRow.js +++ b/packages/discord.js/src/structures/ActionRow.js @@ -1,7 +1,5 @@ 'use strict'; -const { deprecate } = require('node:util'); -const { isJSONEncodable } = require('@discordjs/util'); const Component = require('./Component'); const { createComponent } = require('../util/Components'); @@ -21,19 +19,6 @@ class ActionRow extends Component { this.components = components.map(component => createComponent(component)); } - /** - * Creates a new action row builder from JSON data - * @method from - * @memberof ActionRow - * @param {ActionRowBuilder|ActionRow|APIActionRowComponent} other The other data - * @returns {ActionRowBuilder} - * @deprecated Use {@link ActionRowBuilder.from | ActionRowBuilder#from} instead. - */ - static from = deprecate( - other => new this(isJSONEncodable(other) ? other.toJSON() : other), - 'ActionRow.from() is deprecated. Use ActionRowBuilder.from() instead.', - ); - /** * Returns the API-compatible JSON for this component * @returns {APIActionRowComponent} diff --git a/packages/discord.js/src/structures/BaseGuildEmoji.js b/packages/discord.js/src/structures/BaseGuildEmoji.js index a5c2d5da1bf8..0eb29670d99b 100644 --- a/packages/discord.js/src/structures/BaseGuildEmoji.js +++ b/packages/discord.js/src/structures/BaseGuildEmoji.js @@ -62,14 +62,4 @@ class BaseGuildEmoji extends Emoji { * @returns {string} */ -/** - * Returns a URL for the emoji. - * @name url - * @memberof BaseGuildEmoji - * @instance - * @type {string} - * @readonly - * @deprecated Use {@link BaseGuildEmoji#imageURL} instead. - */ - module.exports = BaseGuildEmoji; diff --git a/packages/discord.js/src/structures/BaseInteraction.js b/packages/discord.js/src/structures/BaseInteraction.js index 28d1e4b35ad3..1386a75f9eb4 100644 --- a/packages/discord.js/src/structures/BaseInteraction.js +++ b/packages/discord.js/src/structures/BaseInteraction.js @@ -1,6 +1,5 @@ 'use strict'; -const { deprecate } = require('node:util'); const { Collection } = require('@discordjs/collection'); const { DiscordSnowflake } = require('@sapphire/snowflake'); const { InteractionType, ApplicationCommandType, ComponentType } = require('discord-api-types/v10'); @@ -259,15 +258,6 @@ class BaseInteraction extends Base { return this.type === InteractionType.MessageComponent && this.componentType === ComponentType.Button; } - /** - * Indicates whether this interaction is a {@link StringSelectMenuInteraction}. - * @returns {boolean} - * @deprecated Use {@link BaseInteraction#isStringSelectMenu} instead. - */ - isSelectMenu() { - return this.isStringSelectMenu(); - } - /** * Indicates whether this interaction is a select menu of any known type. * @returns {boolean} @@ -325,9 +315,4 @@ class BaseInteraction extends Base { } } -BaseInteraction.prototype.isSelectMenu = deprecate( - BaseInteraction.prototype.isSelectMenu, - 'BaseInteraction#isSelectMenu() is deprecated. Use BaseInteraction#isStringSelectMenu() instead.', -); - module.exports = BaseInteraction; diff --git a/packages/discord.js/src/structures/CommandInteraction.js b/packages/discord.js/src/structures/CommandInteraction.js index 0d435deeb446..88086f9605b2 100644 --- a/packages/discord.js/src/structures/CommandInteraction.js +++ b/packages/discord.js/src/structures/CommandInteraction.js @@ -153,7 +153,6 @@ class CommandInteraction extends BaseInteraction { deleteReply() {} followUp() {} showModal() {} - sendPremiumRequired() {} awaitModalSubmit() {} } diff --git a/packages/discord.js/src/structures/Emoji.js b/packages/discord.js/src/structures/Emoji.js index 9451fb043b0b..0dd368e5ddf6 100644 --- a/packages/discord.js/src/structures/Emoji.js +++ b/packages/discord.js/src/structures/Emoji.js @@ -1,12 +1,9 @@ 'use strict'; -const process = require('node:process'); const { formatEmoji } = require('@discordjs/formatters'); const { DiscordSnowflake } = require('@sapphire/snowflake'); const Base = require('./Base'); -let deprecationEmittedForURL = false; - /** * Represents an emoji, see {@link ApplicationEmoji}, {@link GuildEmoji} and {@link ReactionEmoji}. * @extends {Base} @@ -52,21 +49,6 @@ class Emoji extends Base { return this.id && this.client.rest.cdn.emoji(this.id, options); } - /** - * Returns a URL for the emoji or `null` if this is not a custom emoji. - * @type {?string} - * @readonly - * @deprecated Use {@link Emoji#imageURL} instead. - */ - get url() { - if (!deprecationEmittedForURL) { - process.emitWarning('The Emoji#url getter is deprecated. Use Emoji#imageURL() instead.', 'DeprecationWarning'); - deprecationEmittedForURL = true; - } - - return this.imageURL({ extension: this.animated ? 'gif' : 'png' }); - } - /** * The timestamp the emoji was created at, or null if unicode * @type {?number} diff --git a/packages/discord.js/src/structures/Invite.js b/packages/discord.js/src/structures/Invite.js index 4f597d20063b..655d947c7961 100644 --- a/packages/discord.js/src/structures/Invite.js +++ b/packages/discord.js/src/structures/Invite.js @@ -4,7 +4,6 @@ const { RouteBases, Routes, PermissionFlagsBits } = require('discord-api-types/v const Base = require('./Base'); const { GuildScheduledEvent } = require('./GuildScheduledEvent'); const IntegrationApplication = require('./IntegrationApplication'); -const InviteStageInstance = require('./InviteStageInstance'); const { DiscordjsError, ErrorCodes } = require('../errors'); /** @@ -202,17 +201,6 @@ class Invite extends Base { this._expiresTimestamp ??= null; } - if ('stage_instance' in data) { - /** - * The stage instance data if there is a public {@link StageInstance} in the stage channel this invite is for - * @type {?InviteStageInstance} - * @deprecated - */ - this.stageInstance = new InviteStageInstance(this.client, data.stage_instance, this.channel.id, this.guild.id); - } else { - this.stageInstance ??= null; - } - if ('guild_scheduled_event' in data) { /** * The guild scheduled event data if there is a {@link GuildScheduledEvent} in the channel this invite is for diff --git a/packages/discord.js/src/structures/InviteStageInstance.js b/packages/discord.js/src/structures/InviteStageInstance.js deleted file mode 100644 index 21ede43a6c59..000000000000 --- a/packages/discord.js/src/structures/InviteStageInstance.js +++ /dev/null @@ -1,87 +0,0 @@ -'use strict'; - -const { Collection } = require('@discordjs/collection'); -const Base = require('./Base'); - -/** - * Represents the data about a public {@link StageInstance} in an {@link Invite}. - * @extends {Base} - * @deprecated - */ -class InviteStageInstance extends Base { - constructor(client, data, channelId, guildId) { - super(client); - - /** - * The id of the stage channel this invite is for - * @type {Snowflake} - */ - this.channelId = channelId; - - /** - * The stage channel's guild id - * @type {Snowflake} - */ - this.guildId = guildId; - - /** - * The members speaking in the stage channel - * @type {Collection} - */ - this.members = new Collection(); - - this._patch(data); - } - - _patch(data) { - if ('topic' in data) { - /** - * The topic of the stage instance - * @type {string} - */ - this.topic = data.topic; - } - - if ('participant_count' in data) { - /** - * The number of users in the stage channel - * @type {number} - */ - this.participantCount = data.participant_count; - } - - if ('speaker_count' in data) { - /** - * The number of users speaking in the stage channel - * @type {number} - */ - this.speakerCount = data.speaker_count; - } - - this.members.clear(); - for (const rawMember of data.members) { - const member = this.guild.members._add(rawMember); - this.members.set(member.id, member); - } - } - - /** - * The stage channel this invite is for - * @type {?StageChannel} - * @readonly - */ - get channel() { - return this.client.channels.resolve(this.channelId); - } - - /** - * The guild of the stage channel this invite is for - * @type {?Guild} - * @readonly - */ - get guild() { - return this.client.guilds.resolve(this.guildId); - } -} - -module.exports = InviteStageInstance; diff --git a/packages/discord.js/src/structures/MessageComponentInteraction.js b/packages/discord.js/src/structures/MessageComponentInteraction.js index 2e6df11e5611..47b31e04c12c 100644 --- a/packages/discord.js/src/structures/MessageComponentInteraction.js +++ b/packages/discord.js/src/structures/MessageComponentInteraction.js @@ -99,7 +99,6 @@ class MessageComponentInteraction extends BaseInteraction { deferUpdate() {} update() {} showModal() {} - sendPremiumRequired() {} awaitModalSubmit() {} } diff --git a/packages/discord.js/src/structures/ModalSubmitInteraction.js b/packages/discord.js/src/structures/ModalSubmitInteraction.js index ba94190436da..559807bfa078 100644 --- a/packages/discord.js/src/structures/ModalSubmitInteraction.js +++ b/packages/discord.js/src/structures/ModalSubmitInteraction.js @@ -118,7 +118,6 @@ class ModalSubmitInteraction extends BaseInteraction { followUp() {} deferUpdate() {} update() {} - sendPremiumRequired() {} } InteractionResponses.applyToClass(ModalSubmitInteraction, 'showModal'); diff --git a/packages/discord.js/src/structures/SelectMenuBuilder.js b/packages/discord.js/src/structures/SelectMenuBuilder.js deleted file mode 100644 index a77937054777..000000000000 --- a/packages/discord.js/src/structures/SelectMenuBuilder.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -const process = require('node:process'); -const StringSelectMenuBuilder = require('./StringSelectMenuBuilder'); - -let deprecationEmitted = false; - -/** - * @deprecated Use {@link StringSelectMenuBuilder} instead. - * @extends {StringSelectMenuBuilder} - */ -class SelectMenuBuilder extends StringSelectMenuBuilder { - constructor(...params) { - super(...params); - - if (!deprecationEmitted) { - process.emitWarning( - 'The SelectMenuBuilder class is deprecated. Use StringSelectMenuBuilder instead.', - 'DeprecationWarning', - ); - deprecationEmitted = true; - } - } -} - -module.exports = SelectMenuBuilder; diff --git a/packages/discord.js/src/structures/SelectMenuComponent.js b/packages/discord.js/src/structures/SelectMenuComponent.js deleted file mode 100644 index 2cd8097c95f3..000000000000 --- a/packages/discord.js/src/structures/SelectMenuComponent.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -const process = require('node:process'); -const StringSelectMenuComponent = require('./StringSelectMenuComponent'); - -let deprecationEmitted = false; - -/** - * @deprecated Use {@link StringSelectMenuComponent} instead. - * @extends {StringSelectMenuComponent} - */ -class SelectMenuComponent extends StringSelectMenuComponent { - constructor(...params) { - super(...params); - - if (!deprecationEmitted) { - process.emitWarning( - 'The SelectMenuComponent class is deprecated. Use StringSelectMenuComponent instead.', - 'DeprecationWarning', - ); - deprecationEmitted = true; - } - } -} - -module.exports = SelectMenuComponent; diff --git a/packages/discord.js/src/structures/SelectMenuInteraction.js b/packages/discord.js/src/structures/SelectMenuInteraction.js deleted file mode 100644 index a09655958846..000000000000 --- a/packages/discord.js/src/structures/SelectMenuInteraction.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -const process = require('node:process'); -const StringSelectMenuInteraction = require('./StringSelectMenuInteraction'); - -let deprecationEmitted = false; - -/** - * @deprecated Use {@link StringSelectMenuInteraction} instead. - * @extends {StringSelectMenuInteraction} - */ -class SelectMenuInteraction extends StringSelectMenuInteraction { - constructor(...params) { - super(...params); - - if (!deprecationEmitted) { - process.emitWarning( - 'The SelectMenuInteraction class is deprecated. Use StringSelectMenuInteraction instead.', - 'DeprecationWarning', - ); - deprecationEmitted = true; - } - } -} - -module.exports = SelectMenuInteraction; diff --git a/packages/discord.js/src/structures/SelectMenuOptionBuilder.js b/packages/discord.js/src/structures/SelectMenuOptionBuilder.js deleted file mode 100644 index 85309d1542bb..000000000000 --- a/packages/discord.js/src/structures/SelectMenuOptionBuilder.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -const process = require('node:process'); -const StringSelectMenuOptionBuilder = require('./StringSelectMenuOptionBuilder'); - -let deprecationEmitted = false; - -/** - * @deprecated Use {@link StringSelectMenuOptionBuilder} instead. - * @extends {StringSelectMenuOptionBuilder} - */ -class SelectMenuOptionBuilder extends StringSelectMenuOptionBuilder { - constructor(...params) { - super(...params); - - if (!deprecationEmitted) { - process.emitWarning( - 'The SelectMenuOptionBuilder class is deprecated. Use StringSelectMenuOptionBuilder instead.', - 'DeprecationWarning', - ); - deprecationEmitted = true; - } - } -} - -module.exports = SelectMenuOptionBuilder; diff --git a/packages/discord.js/src/structures/StageInstance.js b/packages/discord.js/src/structures/StageInstance.js index 97f65df1d9a6..632f7b0c78d8 100644 --- a/packages/discord.js/src/structures/StageInstance.js +++ b/packages/discord.js/src/structures/StageInstance.js @@ -53,17 +53,6 @@ class StageInstance extends Base { this.privacyLevel = data.privacy_level; } - if ('discoverable_disabled' in data) { - /** - * Whether or not stage discovery is disabled - * @type {?boolean} - * @deprecated See https://github.com/discord/discord-api-docs/pull/4296 for more information - */ - this.discoverableDisabled = data.discoverable_disabled; - } else { - this.discoverableDisabled ??= null; - } - if ('guild_scheduled_event_id' in data) { /** * The associated guild scheduled event id of this stage instance diff --git a/packages/discord.js/src/structures/StringSelectMenuBuilder.js b/packages/discord.js/src/structures/StringSelectMenuBuilder.js index ac555e745401..bd123e4af8e6 100644 --- a/packages/discord.js/src/structures/StringSelectMenuBuilder.js +++ b/packages/discord.js/src/structures/StringSelectMenuBuilder.js @@ -24,8 +24,8 @@ class StringSelectMenuBuilder extends BuildersSelectMenu { /** * Normalizes a select menu option emoji - * @param {SelectMenuOptionData|APISelectMenuOption} selectMenuOption The option to normalize - * @returns {SelectMenuOptionBuilder|APISelectMenuOption} + * @param {SelectMenuComponentOptionData|APISelectMenuOption} selectMenuOption The option to normalize + * @returns {StringSelectMenuOptionBuilder|APISelectMenuOption} * @private */ static normalizeEmoji(selectMenuOption) { diff --git a/packages/discord.js/src/structures/TeamMember.js b/packages/discord.js/src/structures/TeamMember.js index b3c53987d943..b289ccd72677 100644 --- a/packages/discord.js/src/structures/TeamMember.js +++ b/packages/discord.js/src/structures/TeamMember.js @@ -20,15 +20,6 @@ class TeamMember extends Base { } _patch(data) { - if ('permissions' in data) { - /** - * The permissions this Team Member has with regard to the team - * @type {string[]} - * @deprecated Use {@link TeamMember#role} instead. - */ - this.permissions = data.permissions; - } - if ('membership_state' in data) { /** * The permissions this Team Member has with regard to the team diff --git a/packages/discord.js/src/structures/ThreadChannel.js b/packages/discord.js/src/structures/ThreadChannel.js index 074ff052ac59..a0d8c2b383af 100644 --- a/packages/discord.js/src/structures/ThreadChannel.js +++ b/packages/discord.js/src/structures/ThreadChannel.js @@ -1,8 +1,7 @@ 'use strict'; -const { DiscordAPIError } = require('@discordjs/rest'); const { lazy } = require('@discordjs/util'); -const { RESTJSONErrorCodes, ChannelFlags, ChannelType, PermissionFlagsBits, Routes } = require('discord-api-types/v10'); +const { ChannelFlags, ChannelType, PermissionFlagsBits, Routes } = require('discord-api-types/v10'); const { BaseChannel } = require('./BaseChannel'); const getThreadOnlyChannel = lazy(() => require('./ThreadOnlyChannel')); const TextBasedChannel = require('./interfaces/TextBasedChannel'); @@ -299,15 +298,7 @@ class ThreadChannel extends BaseChannel { throw new DiscordjsError(ErrorCodes.FetchOwnerId, 'thread'); } - // TODO: Remove that catch in the next major version - const member = await this.members._fetchSingle({ ...options, member: this.ownerId }).catch(error => { - if (error instanceof DiscordAPIError && error.code === RESTJSONErrorCodes.UnknownMember) { - return null; - } - - throw error; - }); - + const member = await this.members._fetchSingle({ ...options, member: this.ownerId }); return member; } diff --git a/packages/discord.js/src/structures/User.js b/packages/discord.js/src/structures/User.js index a7df27f42a9f..6025410c30f1 100644 --- a/packages/discord.js/src/structures/User.js +++ b/packages/discord.js/src/structures/User.js @@ -123,17 +123,6 @@ class User extends Base { this.flags = new UserFlagsBitField(data.public_flags); } - if ('avatar_decoration' in data) { - /** - * The user avatar decoration's hash - * @type {?string} - * @deprecated Use `avatarDecorationData` instead - */ - this.avatarDecoration = data.avatar_decoration; - } else { - this.avatarDecoration ??= null; - } - /** * @typedef {Object} AvatarDecorationData * @property {string} asset The avatar decoration hash @@ -192,15 +181,10 @@ class User extends Base { /** * A link to the user's avatar decoration. - * @param {BaseImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - avatarDecorationURL(options = {}) { - if (this.avatarDecorationData) { - return this.client.rest.cdn.avatarDecoration(this.avatarDecorationData.asset); - } - - return this.avatarDecoration && this.client.rest.cdn.avatarDecoration(this.id, this.avatarDecoration, options); + avatarDecorationURL() { + return this.avatarDecorationData ? this.client.rest.cdn.avatarDecoration(this.avatarDecorationData.asset) : null; } /** @@ -311,7 +295,6 @@ class User extends Base { this.flags?.bitfield === user.flags?.bitfield && this.banner === user.banner && this.accentColor === user.accentColor && - this.avatarDecoration === user.avatarDecoration && this.avatarDecorationData?.asset === user.avatarDecorationData?.asset && this.avatarDecorationData?.skuId === user.avatarDecorationData?.skuId ); @@ -334,7 +317,6 @@ class User extends Base { this.flags?.bitfield === user.public_flags && ('banner' in user ? this.banner === user.banner : true) && ('accent_color' in user ? this.accentColor === user.accent_color : true) && - ('avatar_decoration' in user ? this.avatarDecoration === user.avatar_decoration : true) && ('avatar_decoration_data' in user ? this.avatarDecorationData?.asset === user.avatar_decoration_data?.asset && this.avatarDecorationData?.skuId === user.avatar_decoration_data?.sku_id diff --git a/packages/discord.js/src/structures/interfaces/InteractionResponses.js b/packages/discord.js/src/structures/interfaces/InteractionResponses.js index 440242a34e56..5c8900530f61 100644 --- a/packages/discord.js/src/structures/interfaces/InteractionResponses.js +++ b/packages/discord.js/src/structures/interfaces/InteractionResponses.js @@ -1,6 +1,5 @@ 'use strict'; -const { deprecate } = require('node:util'); const { isJSONEncodable } = require('@discordjs/util'); const { InteractionResponseType, MessageFlags, Routes, InteractionType } = require('discord-api-types/v10'); const { DiscordjsError, ErrorCodes } = require('../../errors'); @@ -264,23 +263,6 @@ class InteractionResponses { this.replied = true; } - /** - * Responds to the interaction with an upgrade button. - * Only available for applications with monetization enabled. - * @deprecated Sending a premium-style button is the new Discord behaviour. - * @returns {Promise} - */ - async sendPremiumRequired() { - if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied); - await this.client.rest.post(Routes.interactionCallback(this.id, this.token), { - body: { - type: InteractionResponseType.PremiumRequired, - }, - auth: false, - }); - this.replied = true; - } - /** * An object containing the same properties as {@link CollectorOptions}, but a few less: * @typedef {Object} AwaitModalSubmitOptions @@ -324,7 +306,6 @@ class InteractionResponses { 'deferUpdate', 'update', 'showModal', - 'sendPremiumRequired', 'awaitModalSubmit', ]; @@ -339,10 +320,4 @@ class InteractionResponses { } } -InteractionResponses.prototype.sendPremiumRequired = deprecate( - InteractionResponses.prototype.sendPremiumRequired, - // eslint-disable-next-line max-len - 'InteractionResponses#sendPremiumRequired() is deprecated. Sending a premium-style button is the new Discord behaviour.', -); - module.exports = InteractionResponses; diff --git a/packages/discord.js/src/util/Constants.js b/packages/discord.js/src/util/Constants.js index 8babdfdbea68..0a2f48d0ef26 100644 --- a/packages/discord.js/src/util/Constants.js +++ b/packages/discord.js/src/util/Constants.js @@ -189,56 +189,6 @@ exports.UndeletableMessageTypes = [ MessageType.ThreadStarterMessage, ]; -/** - * The types of messages that can be deleted. The available types are: - * * {@link MessageType.AutoModerationAction} - * * {@link MessageType.ChannelFollowAdd} - * * {@link MessageType.ChannelPinnedMessage} - * * {@link MessageType.ChatInputCommand} - * * {@link MessageType.ContextMenuCommand} - * * {@link MessageType.Default} - * * {@link MessageType.GuildBoost} - * * {@link MessageType.GuildBoostTier1} - * * {@link MessageType.GuildBoostTier2} - * * {@link MessageType.GuildBoostTier3} - * * {@link MessageType.GuildInviteReminder} - * * {@link MessageType.InteractionPremiumUpsell} - * * {@link MessageType.Reply} - * * {@link MessageType.RoleSubscriptionPurchase} - * * {@link MessageType.StageEnd} - * * {@link MessageType.StageRaiseHand} - * * {@link MessageType.StageSpeaker} - * * {@link MessageType.StageStart} - * * {@link MessageType.StageTopic} - * * {@link MessageType.ThreadCreated} - * * {@link MessageType.UserJoin} - * @typedef {MessageType[]} DeletableMessageTypes - * @deprecated This list will no longer be updated. Use {@link UndeletableMessageTypes} instead. - */ -exports.DeletableMessageTypes = [ - MessageType.AutoModerationAction, - MessageType.ChannelFollowAdd, - MessageType.ChannelPinnedMessage, - MessageType.ChatInputCommand, - MessageType.ContextMenuCommand, - MessageType.Default, - MessageType.GuildBoost, - MessageType.GuildBoostTier1, - MessageType.GuildBoostTier2, - MessageType.GuildBoostTier3, - MessageType.GuildInviteReminder, - MessageType.InteractionPremiumUpsell, - MessageType.Reply, - MessageType.RoleSubscriptionPurchase, - MessageType.StageEnd, - MessageType.StageRaiseHand, - MessageType.StageSpeaker, - MessageType.StageStart, - MessageType.StageTopic, - MessageType.ThreadCreated, - MessageType.UserJoin, -]; - /** * A mapping between sticker formats and their respective image formats. * * {@link StickerFormatType.PNG} -> {@link ImageFormat.PNG} diff --git a/packages/discord.js/src/util/Events.js b/packages/discord.js/src/util/Events.js index a8ee63f66a56..a2de59453452 100644 --- a/packages/discord.js/src/util/Events.js +++ b/packages/discord.js/src/util/Events.js @@ -80,7 +80,7 @@ * @property {string} VoiceServerUpdate voiceServerUpdate * @property {string} VoiceStateUpdate voiceStateUpdate * @property {string} Warn warn - * @property {string} WebhooksUpdate webhookUpdate + * @property {string} WebhooksUpdate webhooksUpdate */ // JSDoc for IntelliSense purposes @@ -168,5 +168,5 @@ module.exports = { VoiceServerUpdate: 'voiceServerUpdate', VoiceStateUpdate: 'voiceStateUpdate', Warn: 'warn', - WebhooksUpdate: 'webhookUpdate', + WebhooksUpdate: 'webhooksUpdate', }; diff --git a/packages/discord.js/src/util/Formatters.js b/packages/discord.js/src/util/Formatters.js deleted file mode 100644 index 2dd0d6245f1c..000000000000 --- a/packages/discord.js/src/util/Formatters.js +++ /dev/null @@ -1,413 +0,0 @@ -'use strict'; - -const { deprecate } = require('node:util'); -const { - blockQuote, - bold, - channelMention, - codeBlock, - formatEmoji, - hideLinkEmbed, - hyperlink, - inlineCode, - italic, - quote, - roleMention, - spoiler, - strikethrough, - time, - TimestampStyles, - underscore, - userMention, -} = require('@discordjs/formatters'); - -/** - * Formats an application command name and id into an application command mention. - * @method chatInputApplicationCommandMention - * @param {string} commandName The name of the application command - * @param {string|Snowflake} subcommandGroupOrSubOrId - * The subcommand group name, subcommand name, or application command id - * @param {string|Snowflake} [subcommandNameOrId] The subcommand name or application command id - * @param {string} [commandId] The id of the application command - * @returns {string} - */ - -/** - * Wraps the content inside a code block with an optional language. - * @method codeBlock - * @param {string} contentOrLanguage The language to use or content if a second parameter isn't provided - * @param {string} [content] The content to wrap - * @returns {string} - */ - -/** - * Wraps the content inside \`backticks\`, which formats it as inline code. - * @method inlineCode - * @param {string} content The content to wrap - * @returns {string} - */ - -/** - * Formats the content into italic text. - * @method italic - * @param {string} content The content to wrap - * @returns {string} - */ - -/** - * Formats the content into bold text. - * @method bold - * @param {string} content The content to wrap - * @returns {string} - */ - -/** - * Formats the content into underscored text. - * @method underscore - * @param {string} content The content to wrap - * @returns {string} - */ - -/** - * Formats the content into strike-through text. - * @method strikethrough - * @param {string} content The content to wrap - * @returns {string} - */ - -/** - * Formats the content into a quote. - * This needs to be at the start of the line for Discord to format it. - * @method quote - * @param {string} content The content to wrap - * @returns {string} - */ - -/** - * Formats the content into a block quote. - * This needs to be at the start of the line for Discord to format it. - * @method blockQuote - * @param {string} content The content to wrap - * @returns {string} - */ - -/** - * Wraps the URL into `<>`, which stops it from embedding. - * @method hideLinkEmbed - * @param {string} content The content to wrap - * @returns {string} - */ - -/** - * Formats the content and the URL into a masked URL with an optional title. - * @method hyperlink - * @param {string} content The content to display - * @param {string} url The URL the content links to - * @param {string} [title] The title shown when hovering on the masked link - * @returns {string} - */ - -/** - * Formats the content into spoiler text. - * @method spoiler - * @param {string} content The content to spoiler - * @returns {string} - */ - -/** - * Formats a user id into a user mention. - * @method userMention - * @param {Snowflake} userId The user id to format - * @returns {string} - */ - -/** - * Formats a channel id into a channel mention. - * @method channelMention - * @param {Snowflake} channelId The channel id to format - * @returns {string} - */ - -/** - * Formats a role id into a role mention. - * @method roleMention - * @param {Snowflake} roleId The role id to format - * @returns {string} - */ - -/** - * Formats an emoji id into a fully qualified emoji identifier. - * @method formatEmoji - * @param {Snowflake} emojiId The emoji id to format - * @param {boolean} [animated=false] Whether the emoji is animated - * @returns {string} - */ - -/** - * Formats a channel link for a channel. - * @method channelLink - * @param {Snowflake} channelId The id of the channel - * @param {Snowflake} [guildId] The id of the guild - * @returns {string} - */ - -/** - * Formats a message link for a channel. - * @method messageLink - * @param {Snowflake} channelId The id of the channel - * @param {Snowflake} messageId The id of the message - * @param {Snowflake} [guildId] The id of the guild - * @returns {string} - */ - -/** - * A message formatting timestamp style, as defined in - * [here](https://discord.com/developers/docs/reference#message-formatting-timestamp-styles). - * * `t` Short time format, consisting of hours and minutes, e.g. 16:20. - * * `T` Long time format, consisting of hours, minutes, and seconds, e.g. 16:20:30. - * * `d` Short date format, consisting of day, month, and year, e.g. 20/04/2021. - * * `D` Long date format, consisting of day, month, and year, e.g. 20 April 2021. - * * `f` Short date-time format, consisting of short date and short time formats, e.g. 20 April 2021 16:20. - * * `F` Long date-time format, consisting of long date and short time formats, e.g. Tuesday, 20 April 2021 16:20. - * * `R` Relative time format, consisting of a relative duration format, e.g. 2 months ago. - * @typedef {string} TimestampStylesString - */ - -/** - * Formats a date into a short date-time string. - * @method time - * @param {number|Date} [date] The date to format - * @param {TimestampStylesString} [style] The style to use - * @returns {string} - */ - -/** - * Contains various Discord-specific functions for formatting messages. - * @deprecated This class is redundant as all methods of the class can be imported from discord.js directly. - */ -class Formatters extends null { - /** - * Formats the content into a block quote. - * This needs to be at the start of the line for Discord to format it. - * @method blockQuote - * @memberof Formatters - * @param {string} content The content to wrap - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static blockQuote = deprecate( - blockQuote, - 'Formatters.blockQuote() is deprecated. Import this method directly from discord.js instead.', - ); - - /** - * Formats the content into bold text. - * @method bold - * @memberof Formatters - * @param {string} content The content to wrap - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static bold = deprecate( - bold, - 'Formatters.bold() is deprecated. Import this method directly from discord.js instead.', - ); - - /** - * Formats a channel id into a channel mention. - * @method channelMention - * @memberof Formatters - * @param {Snowflake} channelId The channel id to format - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static channelMention = deprecate( - channelMention, - 'Formatters.channelMention() is deprecated. Import this method directly from discord.js instead.', - ); - - /** - * Wraps the content inside a code block with an optional language. - * @method codeBlock - * @memberof Formatters - * @param {string} contentOrLanguage The language to use or content if a second parameter isn't provided - * @param {string} [content] The content to wrap - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static codeBlock = deprecate( - codeBlock, - 'Formatters.codeBlock() is deprecated. Import this method directly from discord.js instead.', - ); - - /** - * Formats an emoji id into a fully qualified emoji identifier. - * @method formatEmoji - * @memberof Formatters - * @param {string} emojiId The emoji id to format - * @param {boolean} [animated=false] Whether the emoji is animated - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static formatEmoji = deprecate( - formatEmoji, - 'Formatters.formatEmoji() is deprecated. Import this method directly from discord.js instead.', - ); - - /** - * Wraps the URL into `<>`, which stops it from embedding. - * @method hideLinkEmbed - * @memberof Formatters - * @param {string} content The content to wrap - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static hideLinkEmbed = deprecate( - hideLinkEmbed, - 'Formatters.hideLinkEmbed() is deprecated. Import this method directly from discord.js instead.', - ); - - /** - * Formats the content and the URL into a masked URL with an optional title. - * @method hyperlink - * @memberof Formatters - * @param {string} content The content to display - * @param {string} url The URL the content links to - * @param {string} [title] The title shown when hovering on the masked link - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static hyperlink = deprecate( - hyperlink, - 'Formatters.hyperlink() is deprecated. Import this method directly from discord.js instead.', - ); - - /** - * Wraps the content inside \`backticks\`, which formats it as inline code. - * @method inlineCode - * @memberof Formatters - * @param {string} content The content to wrap - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static inlineCode = deprecate( - inlineCode, - 'Formatters.inlineCode() is deprecated. Import this method directly from discord.js instead.', - ); - - /** - * Formats the content into italic text. - * @method italic - * @memberof Formatters - * @param {string} content The content to wrap - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static italic = deprecate( - italic, - 'Formatters.italic() is deprecated. Import this method directly from discord.js instead.', - ); - - /** - * Formats the content into a quote. This needs to be at the start of the line for Discord to format it. - * @method quote - * @memberof Formatters - * @param {string} content The content to wrap - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static quote = deprecate( - quote, - 'Formatters.quote() is deprecated. Import this method directly from discord.js instead.', - ); - - /** - * Formats a role id into a role mention. - * @method roleMention - * @memberof Formatters - * @param {Snowflake} roleId The role id to format - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static roleMention = deprecate( - roleMention, - 'Formatters.roleMention() is deprecated. Import this method directly from discord.js instead.', - ); - - /** - * Formats the content into spoiler text. - * @method spoiler - * @memberof Formatters - * @param {string} content The content to spoiler - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static spoiler = deprecate( - spoiler, - 'Formatters.spoiler() is deprecated. Import this method directly from discord.js instead.', - ); - - /** - * Formats the content into strike-through text. - * @method strikethrough - * @memberof Formatters - * @param {string} content The content to wrap - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static strikethrough = deprecate( - strikethrough, - 'Formatters.strikethrough() is deprecated. Import this method directly from discord.js instead.', - ); - - /** - * Formats a date into a short date-time string. - * @method time - * @memberof Formatters - * @param {number|Date} [date] The date to format - * @param {TimestampStylesString} [style] The style to use - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static time = deprecate( - time, - 'Formatters.time() is deprecated. Import this method directly from discord.js instead.', - ); - - /** - * The message formatting timestamp - * [styles](https://discord.com/developers/docs/reference#message-formatting-timestamp-styles) supported by Discord. - * @type {Object} - * @memberof Formatters - * @deprecated Import this property directly from discord.js instead. - */ - static TimestampStyles = TimestampStyles; - - /** - * Formats the content into underscored text. - * @method underscore - * @memberof Formatters - * @param {string} content The content to wrap - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static underscore = deprecate( - underscore, - 'Formatters.underscore() is deprecated. Import this method directly from discord.js instead.', - ); - - /** - * Formats a user id into a user mention. - * @method userMention - * @memberof Formatters - * @param {Snowflake} userId The user id to format - * @returns {string} - * @deprecated Import this method directly from discord.js instead. - */ - static userMention = deprecate( - userMention, - 'Formatters.userMention() is deprecated. Import this method directly from discord.js instead.', - ); -} - -module.exports = Formatters; diff --git a/packages/discord.js/test/monetization.js b/packages/discord.js/test/monetization.js index 375c7a48f6e7..5628c41cf468 100644 --- a/packages/discord.js/test/monetization.js +++ b/packages/discord.js/test/monetization.js @@ -1,7 +1,8 @@ 'use strict'; -const { token, owner } = require('./auth.js'); -const { Client, Events, codeBlock, GatewayIntentBits } = require('../src'); +const { token, owner, skuId } = require('./auth.js'); +const { Client, Events, codeBlock, GatewayIntentBits, ActionRowBuilder, ButtonBuilder } = require('../src'); +const { ButtonStyle } = require('discord-api-types/v10'); const client = new Client({ intents: GatewayIntentBits.Guilds | GatewayIntentBits.GuildMessages }); @@ -35,7 +36,14 @@ client.on(Events.InteractionCreate, async interaction => { console.log('interaction.entitlements', interaction.entitlements); if (interaction.commandName === 'test') { - await interaction.sendPremiumRequired(); + await interaction.reply({ + content: ':3:3:3', + components: [ + new ActionRowBuilder().setComponents( + new ButtonBuilder().setCustomId('test').setLabel('test').setStyle(ButtonStyle.Premium).setSKUId(skuId), + ), + ], + }); } }); diff --git a/packages/discord.js/test/tester2000.js b/packages/discord.js/test/tester2000.js index 548299802be1..a7e2c3c758e0 100644 --- a/packages/discord.js/test/tester2000.js +++ b/packages/discord.js/test/tester2000.js @@ -3,7 +3,7 @@ const process = require('node:process'); const { GatewayIntentBits } = require('discord-api-types/v10'); const { token, prefix, owner } = require('./auth.js'); -const { Client, Options, Formatters } = require('../src'); +const { Client, Options, codeBlock } = require('../src'); // eslint-disable-next-line no-console const log = (...args) => console.log(process.uptime().toFixed(3), ...args); @@ -44,7 +44,7 @@ const commands = { console.error(err.stack); res = err.message; } - message.channel.send(Formatters.codeBlock(res)); + message.channel.send(codeBlock(res)); }, ping: message => message.channel.send('pong'), }; diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 51c0f07fca94..40fa9b21552b 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -17,25 +17,6 @@ import { type RestOrArray, ApplicationCommandOptionAllowedChannelTypes, } from '@discordjs/builders'; -import { - blockQuote, - bold, - channelMention, - codeBlock, - formatEmoji, - hideLinkEmbed, - hyperlink, - inlineCode, - italic, - quote, - roleMention, - spoiler, - strikethrough, - time, - TimestampStyles, - underscore, - userMention, -} from '@discordjs/formatters'; import { Awaitable, JSONEncodable } from '@discordjs/util'; import { Collection, ReadonlyCollection } from '@discordjs/collection'; import { BaseImageURLOptions, ImageURLOptions, RawFile, REST, RESTOptions } from '@discordjs/rest'; @@ -220,7 +201,6 @@ import { RawInteractionData, RawInviteData, RawInviteGuildData, - RawInviteStageInstance, RawMessageButtonInteractionData, RawMessageComponentInteractionData, RawMessageData, @@ -602,8 +582,6 @@ export abstract class CommandInteraction e | ModalComponentData | APIModalInteractionResponseCallbackData, ): Promise; - /** @deprecated Sending a premium-style button is the new Discord behaviour. */ - public sendPremiumRequired(): Promise; public awaitModalSubmit( options: AwaitModalSubmitOptions, ): Promise>; @@ -784,13 +762,6 @@ export class StringSelectMenuBuilder extends BuilderStringSelectMenuComponent { ): StringSelectMenuBuilder; } -export { - /** @deprecated Use {@link StringSelectMenuBuilder} instead */ - StringSelectMenuBuilder as SelectMenuBuilder, - /** @deprecated Use {@link StringSelectMenuOptionBuilder} instead */ - StringSelectMenuOptionBuilder as SelectMenuOptionBuilder, -}; - export class UserSelectMenuBuilder extends BuilderUserSelectMenuComponent { public constructor(data?: Partial); public static from(other: JSONEncodable | APIUserSelectComponent): UserSelectMenuBuilder; @@ -851,11 +822,6 @@ export class StringSelectMenuComponent extends BaseSelectMenuComponent {} export class RoleSelectMenuComponent extends BaseSelectMenuComponent {} @@ -1033,8 +999,6 @@ export class Client extends BaseClient { public fetchSticker(id: Snowflake): Promise; public fetchStickerPacks(options: { packId: Snowflake }): Promise; public fetchStickerPacks(options?: StickerPackFetchOptions): Promise>; - /** @deprecated Use {@link Client.fetchStickerPacks} instead. */ - public fetchPremiumStickerPacks(): ReturnType; public fetchWebhook(id: Snowflake, token?: string): Promise; public fetchGuildWidget(guild: GuildResolvable): Promise; public generateInvite(options?: InviteGenerationOptions): string; @@ -1932,7 +1896,7 @@ export type Interaction = | ChatInputCommandInteraction | MessageContextMenuCommandInteraction | UserContextMenuCommandInteraction - | AnySelectMenuInteraction + | SelectMenuInteraction | ButtonInteraction | AutocompleteInteraction | ModalSubmitInteraction; @@ -1984,9 +1948,7 @@ export class BaseInteraction extends Base public isMessageContextMenuCommand(): this is MessageContextMenuCommandInteraction; public isModalSubmit(): this is ModalSubmitInteraction; public isUserContextMenuCommand(): this is UserContextMenuCommandInteraction; - /** @deprecated Use {@link BaseInteraction.isStringSelectMenu} instead. */ - public isSelectMenu(): this is StringSelectMenuInteraction; - public isAnySelectMenu(): this is AnySelectMenuInteraction; + public isAnySelectMenu(): this is SelectMenuInteraction; public isStringSelectMenu(): this is StringSelectMenuInteraction; public isUserSelectMenu(): this is UserSelectMenuInteraction; public isRoleSelectMenu(): this is RoleSelectMenuInteraction; @@ -2075,24 +2037,9 @@ export class Invite extends Base { public toJSON(): unknown; public toString(): string; public static InvitesPattern: RegExp; - /** @deprecated Public Stage Instances don't exist anymore */ - public stageInstance: InviteStageInstance | null; public guildScheduledEvent: GuildScheduledEvent | null; } -/** @deprecated Public Stage Instances don't exist anymore */ -export class InviteStageInstance extends Base { - private constructor(client: Client, data: RawInviteStageInstance, channelId: Snowflake, guildId: Snowflake); - public channelId: Snowflake; - public guildId: Snowflake; - public members: Collection; - public topic: string; - public participantCount: number; - public speakerCount: number; - public get channel(): StageChannel | null; - public get guild(): Guild | null; -} - export class InviteGuild extends AnonymousGuild { private constructor(client: Client, data: RawInviteGuildData); public welcomeScreen: WelcomeScreen | null; @@ -2352,8 +2299,6 @@ export class MessageComponentInteraction e | ModalComponentData | APIModalInteractionResponseCallbackData, ): Promise; - /** @deprecated Sending a premium-style button is the new Discord behaviour. */ - public sendPremiumRequired(): Promise; public awaitModalSubmit( options: AwaitModalSubmitOptions, ): Promise>; @@ -2559,8 +2504,6 @@ export class ModalSubmitInteraction extend options: InteractionDeferUpdateOptions & { fetchReply: true }, ): Promise>>; public deferUpdate(options?: InteractionDeferUpdateOptions): Promise>>; - /** @deprecated Sending a premium-style button is the new Discord behaviour. */ - public sendPremiumRequired(): Promise; public inGuild(): this is ModalSubmitInteraction<'raw' | 'cached'>; public inCachedGuild(): this is ModalSubmitInteraction<'cached'>; public inRawGuild(): this is ModalSubmitInteraction<'raw'>; @@ -2861,11 +2804,6 @@ export class StringSelectMenuInteraction< public inRawGuild(): this is StringSelectMenuInteraction<'raw'>; } -export { - /** @deprecated Use {@link StringSelectMenuInteraction} instead */ - StringSelectMenuInteraction as SelectMenuInteraction, -}; - export class UserSelectMenuInteraction< Cached extends CacheType = CacheType, > extends MessageComponentInteraction { @@ -2956,8 +2894,7 @@ export class ChannelSelectMenuInteraction< // Ideally this should be named SelectMenuInteraction, but that's the name of the "old" StringSelectMenuInteraction, meaning // the type name is reserved as a re-export to prevent a breaking change from being made, as such: -// TODO: Rename this to SelectMenuInteraction in the next major -export type AnySelectMenuInteraction = +export type SelectMenuInteraction = | StringSelectMenuInteraction | UserSelectMenuInteraction | RoleSelectMenuInteraction @@ -3142,8 +3079,6 @@ export class StageInstance extends Base { public channelId: Snowflake; public topic: string; public privacyLevel: StageInstancePrivacyLevel; - /** @deprecated See https://github.com/discord/discord-api-docs/pull/4296 for more information */ - public discoverableDisabled: boolean | null; public guildScheduledEventId?: Snowflake; public get channel(): StageChannel | null; public get guild(): Guild | null; @@ -3296,8 +3231,6 @@ export class TeamMember extends Base { private constructor(team: Team, data: RawTeamMemberData); public team: Team; public get id(): Snowflake; - /** @deprecated Use {@link TeamMember.role} instead. */ - public permissions: string[]; public membershipState: TeamMemberMembershipState; public user: User; public role: TeamMemberRole; @@ -3433,8 +3366,6 @@ export class User extends Base { public accentColor: number | null | undefined; public avatar: string | null; - /** @deprecated Use {@link User.avatarDecorationData} instead */ - public avatarDecoration: string | null; public avatarDecorationData: AvatarDecorationData | null; public banner: string | null | undefined; public bot: boolean; @@ -3588,44 +3519,6 @@ export function createComponentBuilder(data: Data): Data; export function createComponentBuilder(data: APIMessageComponent | ComponentBuilder): ComponentBuilder; -/** @deprecated This class is redundant as all methods of the class can be imported from discord.js directly. */ -export class Formatters extends null { - /** @deprecated Import this method directly from discord.js instead. */ - public static blockQuote: typeof blockQuote; - /** @deprecated Import this method directly from discord.js instead. */ - public static bold: typeof bold; - /** @deprecated Import this method directly from discord.js instead. */ - public static channelMention: typeof channelMention; - /** @deprecated Import this method directly from discord.js instead. */ - public static codeBlock: typeof codeBlock; - /** @deprecated Import this method directly from discord.js instead. */ - public static formatEmoji: typeof formatEmoji; - /** @deprecated Import this method directly from discord.js instead. */ - public static hideLinkEmbed: typeof hideLinkEmbed; - /** @deprecated Import this method directly from discord.js instead. */ - public static hyperlink: typeof hyperlink; - /** @deprecated Import this method directly from discord.js instead. */ - public static inlineCode: typeof inlineCode; - /** @deprecated Import this method directly from discord.js instead. */ - public static italic: typeof italic; - /** @deprecated Import this method directly from discord.js instead. */ - public static quote: typeof quote; - /** @deprecated Import this method directly from discord.js instead. */ - public static roleMention: typeof roleMention; - /** @deprecated Import this method directly from discord.js instead. */ - public static spoiler: typeof spoiler; - /** @deprecated Import this method directly from discord.js instead. */ - public static strikethrough: typeof strikethrough; - /** @deprecated Import this method directly from discord.js instead. */ - public static time: typeof time; - /** @deprecated Import this property directly from discord.js instead. */ - public static TimestampStyles: typeof TimestampStyles; - /** @deprecated Import this method directly from discord.js instead. */ - public static underscore: typeof underscore; - /** @deprecated Import this method directly from discord.js instead. */ - public static userMention: typeof userMention; -} - /** @internal */ export function resolveBase64(data: Base64Resolvable): string; /** @internal */ @@ -3869,30 +3762,6 @@ export type UndeletableMessageType = | MessageType.ChannelIconChange | MessageType.ThreadStarterMessage; -/** @deprecated This type will no longer be updated. Use {@link UndeletableMessageType} instead. */ -export type DeletableMessageType = - | MessageType.AutoModerationAction - | MessageType.ChannelFollowAdd - | MessageType.ChannelPinnedMessage - | MessageType.ChatInputCommand - | MessageType.ContextMenuCommand - | MessageType.Default - | MessageType.GuildBoost - | MessageType.GuildBoostTier1 - | MessageType.GuildBoostTier2 - | MessageType.GuildBoostTier3 - | MessageType.GuildInviteReminder - | MessageType.InteractionPremiumUpsell - | MessageType.Reply - | MessageType.RoleSubscriptionPurchase - | MessageType.StageEnd - | MessageType.StageRaiseHand - | MessageType.StageSpeaker - | MessageType.StageStart - | MessageType.StageTopic - | MessageType.ThreadCreated - | MessageType.UserJoin; - export const Constants: { MaxBulkDeletableMessageAge: 1_209_600_000; SweeperKeys: SweeperKey[]; @@ -3904,8 +3773,6 @@ export const Constants: { VoiceBasedChannelTypes: VoiceBasedChannelTypes[]; SelectMenuTypes: SelectMenuType[]; UndeletableMessageTypes: UndeletableMessageType[]; - /** @deprecated This list will no longer be updated. Use {@link Constants.UndeletableMessageTypes} instead. */ - DeletableMessageTypes: DeletableMessageType[]; StickerFormatExtensionMap: Record; }; @@ -3924,25 +3791,8 @@ export enum DiscordjsErrorCodes { TokenMissing = 'TokenMissing', ApplicationCommandPermissionsTokenMissing = 'ApplicationCommandPermissionsTokenMissing', - /** @deprecated WebSocket errors are now handled in `@discordjs/ws` */ - WSCloseRequested = 'WSCloseRequested', - /** @deprecated WebSocket errors are now handled in `@discordjs/ws` */ - WSConnectionExists = 'WSConnectionExists', - /** @deprecated WebSocket errors are now handled in `@discordjs/ws` */ - WSNotOpen = 'WSNotOpen', - /** @deprecated No longer in use */ - ManagerDestroyed = 'ManagerDestroyed', - BitFieldInvalid = 'BitFieldInvalid', - /** @deprecated This error is now handled in `@discordjs/ws` */ - ShardingInvalid = 'ShardingInvalid', - /** @deprecated This error is now handled in `@discordjs/ws` */ - ShardingRequired = 'ShardingRequired', - /** @deprecated This error is now handled in `@discordjs/ws` */ - InvalidIntents = 'InvalidIntents', - /** @deprecated This error is now handled in `@discordjs/ws` */ - DisallowedIntents = 'DisallowedIntents', ShardingNoShards = 'ShardingNoShards', ShardingInProcess = 'ShardingInProcess', ShardingInvalidEvalBroadcast = 'ShardingInvalidEvalBroadcast', @@ -3961,30 +3811,10 @@ export enum DiscordjsErrorCodes { InviteOptionsMissingChannel = 'InviteOptionsMissingChannel', - /** @deprecated Button validation errors are now handled in `@discordjs/builders` */ - ButtonLabel = 'ButtonLabel', - /** @deprecated Button validation errors are now handled in `@discordjs/builders` */ - ButtonURL = 'ButtonURL', - /** @deprecated Button validation errors are now handled in `@discordjs/builders` */ - ButtonCustomId = 'ButtonCustomId', - - /** @deprecated Select Menu validation errors are now handled in `@discordjs/builders` */ - SelectMenuCustomId = 'SelectMenuCustomId', - /** @deprecated Select Menu validation errors are now handled in `@discordjs/builders` */ - SelectMenuPlaceholder = 'SelectMenuPlaceholder', - /** @deprecated Select Menu validation errors are now handled in `@discordjs/builders` */ - SelectOptionLabel = 'SelectOptionLabel', - /** @deprecated Select Menu validation errors are now handled in `@discordjs/builders` */ - SelectOptionValue = 'SelectOptionValue', - /** @deprecated Select Menu validation errors are now handled in `@discordjs/builders` */ - SelectOptionDescription = 'SelectOptionDescription', - InteractionCollectorError = 'InteractionCollectorError', FileNotFound = 'FileNotFound', - /** @deprecated No longer in use */ - UserBannerNotFetched = 'UserBannerNotFetched', UserNoDMChannel = 'UserNoDMChannel', VoiceNotStageChannel = 'VoiceNotStageChannel', @@ -3994,19 +3824,11 @@ export enum DiscordjsErrorCodes { ReqResourceType = 'ReqResourceType', - /** @deprecated This error is now handled in `@discordjs/rest` */ - ImageFormat = 'ImageFormat', - /** @deprecated This error is now handled in `@discordjs/rest` */ - ImageSize = 'ImageSize', - MessageBulkDeleteType = 'MessageBulkDeleteType', MessageContentType = 'MessageContentType', MessageNonceRequired = 'MessageNonceRequired', MessageNonceType = 'MessageNonceType', - /** @deprecated No longer in use */ - SplitMaxLen = 'SplitMaxLen', - BanResolveId = 'BanResolveId', FetchBanResolveId = 'FetchBanResolveId', @@ -4040,16 +3862,11 @@ export enum DiscordjsErrorCodes { EmojiType = 'EmojiType', EmojiManaged = 'EmojiManaged', MissingManageGuildExpressionsPermission = 'MissingManageGuildExpressionsPermission', - /** @deprecated Use {@link DiscordjsErrorCodes.MissingManageGuildExpressionsPermission} instead. */ - MissingManageEmojisAndStickersPermission = 'MissingManageEmojisAndStickersPermission', NotGuildSticker = 'NotGuildSticker', ReactionResolveUser = 'ReactionResolveUser', - /** @deprecated Not used anymore since the introduction of `GUILD_WEB_PAGE_VANITY_URL` feature */ - VanityURL = 'VanityURL', - InviteResolveCode = 'InviteResolveCode', InviteNotFound = 'InviteNotFound', @@ -4064,8 +3881,6 @@ export enum DiscordjsErrorCodes { InteractionAlreadyReplied = 'InteractionAlreadyReplied', InteractionNotReplied = 'InteractionNotReplied', - /** @deprecated Not used anymore since ephemeral replies can now be deleted */ - InteractionEphemeralReplied = 'InteractionEphemeralReplied', CommandInteractionOptionNotFound = 'CommandInteractionOptionNotFound', CommandInteractionOptionType = 'CommandInteractionOptionType', @@ -4417,7 +4232,7 @@ export class GuildMemberManager extends CachedManager; public bulkBan( users: ReadonlyCollection | readonly UserResolvable[], - options?: BulkBanOptions, + options?: BanOptions, ): Promise; public edit(user: UserResolvable, options: GuildMemberEditOptions): Promise; public fetch( @@ -4444,7 +4259,7 @@ export class GuildBanManager extends CachedManager; public bulkCreate( users: ReadonlyCollection | readonly UserResolvable[], - options?: BulkBanOptions, + options?: BanOptions, ): Promise; } @@ -5147,14 +4962,10 @@ export interface AwaitReactionsOptions extends ReactionCollectorOptions { } export interface BanOptions { - /** @deprecated Use {@link BanOptions.deleteMessageSeconds} instead. */ - deleteMessageDays?: number; deleteMessageSeconds?: number; reason?: string; } -export interface BulkBanOptions extends Omit {} - export interface BulkBanResult { bannedUsers: readonly Snowflake[]; failedUsers: readonly Snowflake[]; @@ -5390,8 +5201,6 @@ export interface ClientEvents { typingStart: [typing: Typing]; userUpdate: [oldUser: User | PartialUser, newUser: User]; voiceStateUpdate: [oldState: VoiceState, newState: VoiceState]; - /** @deprecated Use {@link ClientEvents.webhooksUpdate} instead. */ - webhookUpdate: ClientEvents['webhooksUpdate']; webhooksUpdate: [channel: TextChannel | NewsChannel | VoiceChannel | ForumChannel | MediaChannel]; interactionCreate: [interaction: Interaction]; shardDisconnect: [closeEvent: CloseEvent, shardId: number]; @@ -5603,7 +5412,7 @@ export enum Events { VoiceServerUpdate = 'voiceServerUpdate', VoiceStateUpdate = 'voiceStateUpdate', TypingStart = 'typingStart', - WebhooksUpdate = 'webhookUpdate', + WebhooksUpdate = 'webhooksUpdate', InteractionCreate = 'interactionCreate', Error = 'error', Warn = 'warn', diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index 1f1b34f3a0b6..df99d3f29a8f 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -108,7 +108,7 @@ import { StageInstance, ActionRowBuilder, ButtonComponent, - SelectMenuComponent, + StringSelectMenuComponent, RepliableInteraction, ThreadChannelType, Events, @@ -152,9 +152,8 @@ import { ChannelFlagsBitField, GuildForumThreadManager, GuildTextThreadManager, - AnySelectMenuInteraction, + SelectMenuInteraction, StringSelectMenuInteraction, - StringSelectMenuComponent, UserSelectMenuInteraction, RoleSelectMenuInteraction, ChannelSelectMenuInteraction, @@ -213,7 +212,7 @@ import { SendableChannels, PollData, } from '.'; -import { expectAssignable, expectDeprecated, expectNotAssignable, expectNotType, expectType } from 'tsd'; +import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd'; import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders'; import { ReadonlyCollection } from '@discordjs/collection'; @@ -1780,10 +1779,9 @@ if (interaction.inGuild()) { client.on('interactionCreate', async interaction => { if (interaction.type === InteractionType.MessageComponent) { - expectType(interaction); + expectType(interaction); expectType(interaction.component); expectType(interaction.message); - expectDeprecated(interaction.sendPremiumRequired()); if (interaction.inCachedGuild()) { expectAssignable(interaction); expectType(interaction.component); @@ -1948,7 +1946,7 @@ client.on('interactionCreate', async interaction => { expectType(interaction.message); if (interaction.inCachedGuild()) { expectAssignable(interaction); - expectType(interaction.component); + expectType(interaction.component); expectType>(interaction.message); expectType(interaction.guild); expectType>>(interaction.reply({ fetchReply: true })); @@ -1960,7 +1958,7 @@ client.on('interactionCreate', async interaction => { expectType>>(interaction.reply({ fetchReply: true })); } else if (interaction.inGuild()) { expectAssignable(interaction); - expectType(interaction.component); + expectType(interaction.component); expectType(interaction.message); expectType(interaction.guild); expectType>(interaction.reply({ fetchReply: true })); @@ -1971,7 +1969,6 @@ client.on('interactionCreate', async interaction => { interaction.type === InteractionType.ApplicationCommand && interaction.commandType === ApplicationCommandType.ChatInput ) { - expectDeprecated(interaction.sendPremiumRequired()); if (interaction.inRawGuild()) { expectNotAssignable>(interaction); expectAssignable(interaction); @@ -2095,10 +2092,6 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.followUp({ content: 'a' })); } } - - if (interaction.isModalSubmit()) { - expectDeprecated(interaction.sendPremiumRequired()); - } }); declare const shard: Shard; @@ -2422,10 +2415,10 @@ expectType(partialGroupDMChannel.flags); // Select menu type narrowing if (interaction.isAnySelectMenu()) { - expectType(interaction); + expectType(interaction); } -declare const anySelectMenu: AnySelectMenuInteraction; +declare const anySelectMenu: SelectMenuInteraction; if (anySelectMenu.isStringSelectMenu()) { expectType(anySelectMenu); @@ -2559,10 +2552,6 @@ declare const sku: SKU; client.on(Events.InteractionCreate, async interaction => { expectType>(interaction.entitlements); - - if (interaction.isRepliable()) { - await interaction.sendPremiumRequired(); - } }); } diff --git a/packages/discord.js/typings/rawDataTypes.d.ts b/packages/discord.js/typings/rawDataTypes.d.ts index 794daafa4069..b6c29feb7992 100644 --- a/packages/discord.js/typings/rawDataTypes.d.ts +++ b/packages/discord.js/typings/rawDataTypes.d.ts @@ -25,7 +25,6 @@ import { APIInteractionDataResolvedGuildMember, APIInteractionGuildMember, APIInvite, - APIInviteStageInstance, APIMessage, APIMessageButtonInteractionData, APIMessageComponentInteraction, @@ -148,8 +147,6 @@ export type RawInviteData = | (GatewayInviteCreateDispatchData & { channel: GuildChannel; guild: Guild }) | (GatewayInviteDeleteDispatchData & { channel: GuildChannel; guild: Guild }); -export type RawInviteStageInstance = APIInviteStageInstance; - export type RawMessageData = APIMessage; export type RawPartialMessageData = GatewayMessageUpdateDispatchData;