Skip to content

Commit

Permalink
refactor: deprecate v13 properties and methods (#7782)
Browse files Browse the repository at this point in the history
* refactor: deprecate splitting

* refactor: deprecate `IntegrationApplication#summary`

#7729

* docs: amend store channel wording

* refactor: deprecate fetching of application assets

* docs: deprecate vip field in voice regions
  • Loading branch information
Jiralite committed Apr 17, 2022
1 parent 1040ce0 commit b9802f4
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/structures/IntegrationApplication.js
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/structures/StoreChannel.js
Expand Up @@ -4,7 +4,7 @@ const GuildChannel = require('./GuildChannel');

/**
* Represents a guild store channel on Discord.
* <warn>Store channels are deprecated and will be removed from Discord in March 2022. See
* <warn>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.</warn>
* @extends {GuildChannel}
Expand Down
1 change: 1 addition & 0 deletions src/structures/VoiceRegion.js
Expand Up @@ -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;

Expand Down
13 changes: 13 additions & 0 deletions 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
Expand Down Expand Up @@ -103,8 +106,18 @@ class Application extends Base {
/**
* Gets the application's rich presence assets.
* @returns {Promise<Array<ApplicationAsset>>}
* @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,
Expand Down
11 changes: 11 additions & 0 deletions src/util/Util.js
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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];
Expand Down
4 changes: 4 additions & 0 deletions typings/index.d.ts
Expand Up @@ -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<ApplicationAsset[]>;
public iconURL(options?: StaticImageURLOptions): string | null;
public toJSON(): unknown;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit b9802f4

Please sign in to comment.