From b9802f4b6f25da62a0bff049ccc165cce8c9d856 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Sun, 17 Apr 2022 09:52:50 +0100 Subject: [PATCH] refactor: deprecate v13 properties and methods (#7782) * refactor: deprecate splitting * refactor: deprecate `IntegrationApplication#summary` https://github.com/discordjs/discord.js/pull/7729 * docs: amend store channel wording * refactor: deprecate fetching of application assets * docs: deprecate vip field in voice regions --- src/structures/IntegrationApplication.js | 1 + src/structures/StoreChannel.js | 2 +- src/structures/VoiceRegion.js | 1 + src/structures/interfaces/Application.js | 13 +++++++++++++ src/util/Util.js | 11 +++++++++++ typings/index.d.ts | 4 ++++ 6 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/structures/IntegrationApplication.js b/src/structures/IntegrationApplication.js index 1a81df1f0173..61cb199e258b 100644 --- a/src/structures/IntegrationApplication.js +++ b/src/structures/IntegrationApplication.js @@ -54,6 +54,7 @@ class IntegrationApplication extends Application { /** * The application's summary * @type {?string} + * @deprecated This property is no longer being sent by the API. */ this.summary = data.summary; } else { diff --git a/src/structures/StoreChannel.js b/src/structures/StoreChannel.js index e8bd745fdc8c..3db1e40c2bbd 100644 --- a/src/structures/StoreChannel.js +++ b/src/structures/StoreChannel.js @@ -4,7 +4,7 @@ const GuildChannel = require('./GuildChannel'); /** * Represents a guild store channel on Discord. - * Store channels are deprecated and will be removed from Discord in March 2022. See + * Store channels have been removed from Discord. See * [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479) * for more information. * @extends {GuildChannel} diff --git a/src/structures/VoiceRegion.js b/src/structures/VoiceRegion.js index fe399b49d24e..7cf6c881aff8 100644 --- a/src/structures/VoiceRegion.js +++ b/src/structures/VoiceRegion.js @@ -22,6 +22,7 @@ class VoiceRegion { /** * Whether the region is VIP-only * @type {boolean} + * @deprecated This property is no longer being sent by the API. */ this.vip = data.vip; diff --git a/src/structures/interfaces/Application.js b/src/structures/interfaces/Application.js index bc3b09c0052e..2334bdaa698d 100644 --- a/src/structures/interfaces/Application.js +++ b/src/structures/interfaces/Application.js @@ -1,11 +1,14 @@ 'use strict'; +const process = require('node:process'); const { ClientApplicationAssetTypes, Endpoints } = require('../../util/Constants'); const SnowflakeUtil = require('../../util/SnowflakeUtil'); const Base = require('../Base'); const AssetTypes = Object.keys(ClientApplicationAssetTypes); +let deprecationEmittedForFetchAssets = false; + /** * Represents an OAuth2 Application. * @abstract @@ -103,8 +106,18 @@ class Application extends Base { /** * Gets the application's rich presence assets. * @returns {Promise>} + * @deprecated This will be removed in the next major as it is unsupported functionality. */ async fetchAssets() { + if (!deprecationEmittedForFetchAssets) { + process.emitWarning( + 'Application#fetchAssets is deprecated as it is unsupported and will be removed in the next major version.', + 'DeprecationWarning', + ); + + deprecationEmittedForFetchAssets = true; + } + const assets = await this.client.api.oauth2.applications(this.id).assets.get(); return assets.map(a => ({ id: a.id, diff --git a/src/util/Util.js b/src/util/Util.js index d33da68d1b36..12e84e9fd7fd 100644 --- a/src/util/Util.js +++ b/src/util/Util.js @@ -10,6 +10,7 @@ const { Error: DiscordError, RangeError, TypeError } = require('../errors'); const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k); const isObject = d => typeof d === 'object' && d !== null; +let deprecationEmittedForSplitMessage = false; let deprecationEmittedForRemoveMentions = false; /** @@ -70,9 +71,19 @@ class Util extends null { * Splits a string into multiple chunks at a designated character that do not exceed a specific length. * @param {string} text Content to split * @param {SplitOptions} [options] Options controlling the behavior of the split + * @deprecated This will be removed in the next major version. * @returns {string[]} */ static splitMessage(text, { maxLength = 2_000, char = '\n', prepend = '', append = '' } = {}) { + if (!deprecationEmittedForSplitMessage) { + process.emitWarning( + 'The Util.splitMessage method is deprecated and will be removed in the next major version.', + 'DeprecationWarning', + ); + + deprecationEmittedForSplitMessage = true; + } + text = Util.verifyString(text); if (text.length <= maxLength) return [text]; let splitText = [text]; diff --git a/typings/index.d.ts b/typings/index.d.ts index 3a3a5ac3466b..90eff1c31330 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -212,6 +212,7 @@ export abstract class Application extends Base { public id: Snowflake; public name: string | null; public coverURL(options?: StaticImageURLOptions): string | null; + /** @deprecated This method is deprecated as it is unsupported and will be removed in the next major version. */ public fetchAssets(): Promise; public iconURL(options?: StaticImageURLOptions): string | null; public toJSON(): unknown; @@ -1330,6 +1331,7 @@ export class IntegrationApplication extends Application { public termsOfServiceURL: string | null; public privacyPolicyURL: string | null; public rpcOrigins: string[]; + /** @deprecated This property is no longer being sent by the API. */ public summary: string | null; public hook: boolean | null; public cover: string | null; @@ -2627,6 +2629,7 @@ export class Util extends null { route: unknown, reason?: string, ): Promise<{ id: Snowflake; position: number }[]>; + /** @deprecated This will be removed in the next major version. */ public static splitMessage(text: string, options?: SplitOptions): string[]; public static resolveAutoArchiveMaxLimit(guild: Guild): number; } @@ -2671,6 +2674,7 @@ export class VoiceRegion { public id: string; public name: string; public optimal: boolean; + /** @deprecated This property is no longer being sent by the API. */ public vip: boolean; public toJSON(): unknown; }