Skip to content

Commit

Permalink
refactor: modify deprecation message
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiralite committed Jul 27, 2022
1 parent 1a88564 commit 080622e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 52 deletions.
77 changes: 43 additions & 34 deletions packages/discord.js/src/util/Formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const {

/**
* Contains various Discord-specific functions for formatting messages.
* @deprecated This class is redundant as all methods of the class are top-level exports.
* @deprecated This class is redundant as all methods of the class can be imported from discord.js directly.
*/
class Formatters extends null {
/**
Expand All @@ -165,11 +165,11 @@ class Formatters extends null {
* @memberof Formatters
* @param {string} content The content to wrap
* @returns {string}
* @deprecated Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static blockQuote = deprecate(
blockQuote,
'Formatters.blockQuote() is deprecated. Use this method as a top-level function instead.',
'Formatters.blockQuote() is deprecated. Import this method directly from discord.js instead.',
);

/**
Expand All @@ -178,21 +178,24 @@ class Formatters extends null {
* @memberof Formatters
* @param {string} content The content to wrap
* @returns {string}
* @deprecated Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static bold = deprecate(bold, 'Formatters.bold() is deprecated. Use this method as a top-level function 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 Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static channelMention = deprecate(
channelMention,
'Formatters.channelMention() is deprecated. Use this method as a top-level function instead.',
'Formatters.channelMention() is deprecated. Import this method directly from discord.js instead.',
);

/**
Expand All @@ -202,11 +205,11 @@ class Formatters extends null {
* @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 Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static codeBlock = deprecate(
codeBlock,
'Formatters.codeBlock() is deprecated. Use this method as a top-level function instead.',
'Formatters.codeBlock() is deprecated. Import this method directly from discord.js instead.',
);

/**
Expand All @@ -216,11 +219,11 @@ class Formatters extends null {
* @param {string} emojiId The emoji id to format
* @param {boolean} [animated=false] Whether the emoji is animated
* @returns {string}
* @deprecated Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static formatEmoji = deprecate(
formatEmoji,
'Formatters.formatEmoji() is deprecated. Use this method as a top-level function instead.',
'Formatters.formatEmoji() is deprecated. Import this method directly from discord.js instead.',
);

/**
Expand All @@ -229,11 +232,11 @@ class Formatters extends null {
* @memberof Formatters
* @param {string} content The content to wrap
* @returns {string}
* @deprecated Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static hideLinkEmbed = deprecate(
hideLinkEmbed,
'Formatters.hideLinkEmbed() is deprecated. Use this method as a top-level function instead.',
'Formatters.hideLinkEmbed() is deprecated. Import this method directly from discord.js instead.',
);

/**
Expand All @@ -244,11 +247,11 @@ class Formatters extends null {
* @param {string} url The URL the content links to
* @param {string} [title] The title shown when hovering on the masked link
* @returns {string}
* @deprecated Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static hyperlink = deprecate(
hyperlink,
'Formatters.hyperlink() is deprecated. Use this method as a top-level function instead.',
'Formatters.hyperlink() is deprecated. Import this method directly from discord.js instead.',
);

/**
Expand All @@ -257,11 +260,11 @@ class Formatters extends null {
* @memberof Formatters
* @param {string} content The content to wrap
* @returns {string}
* @deprecated Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static inlineCode = deprecate(
inlineCode,
'Formatters.inlineCode() is deprecated. Use this method as a top-level function instead.',
'Formatters.inlineCode() is deprecated. Import this method directly from discord.js instead.',
);

/**
Expand All @@ -270,11 +273,11 @@ class Formatters extends null {
* @memberof Formatters
* @param {string} content The content to wrap
* @returns {string}
* @deprecated Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static italic = deprecate(
italic,
'Formatters.italic() is deprecated. Use this method as a top-level function instead.',
'Formatters.italic() is deprecated. Import this method directly from discord.js instead.',
);

/**
Expand All @@ -283,21 +286,24 @@ class Formatters extends null {
* @memberof Formatters
* @param {string} content The content to wrap
* @returns {string}
* @deprecated Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static quote = deprecate(quote, 'Formatters.quote() is deprecated. Use this method as a top-level function 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 Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static roleMention = deprecate(
roleMention,
'Formatters.roleMention() is deprecated. Use this method as a top-level function instead.',
'Formatters.roleMention() is deprecated. Import this method directly from discord.js instead.',
);

/**
Expand All @@ -306,11 +312,11 @@ class Formatters extends null {
* @memberof Formatters
* @param {string} content The content to spoiler
* @returns {string}
* @deprecated Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static spoiler = deprecate(
spoiler,
'Formatters.spoiler() is deprecated. Use this method as a top-level function instead.',
'Formatters.spoiler() is deprecated. Import this method directly from discord.js instead.',
);

/**
Expand All @@ -319,11 +325,11 @@ class Formatters extends null {
* @memberof Formatters
* @param {string} content The content to wrap
* @returns {string}
* @deprecated Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static strikethrough = deprecate(
strikethrough,
'Formatters.strikethrough() is deprecated. Use this method as a top-level function instead.',
'Formatters.strikethrough() is deprecated. Import this method directly from discord.js instead.',
);

/**
Expand All @@ -333,16 +339,19 @@ class Formatters extends null {
* @param {number|Date} [date] The date to format
* @param {TimestampStylesString} [style] The style to use
* @returns {string}
* @deprecated Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static time = deprecate(time, 'Formatters.time() is deprecated. Use this method as a top-level function 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<string, TimestampStylesString>}
* @memberof Formatters
* @deprecated Use this property as a top-level property instead.
* @deprecated Import this property directly from discord.js instead.
*/
static TimestampStyles = TimestampStyles;

Expand All @@ -352,11 +361,11 @@ class Formatters extends null {
* @memberof Formatters
* @param {string} content The content to wrap
* @returns {string}
* @deprecated Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static underscore = deprecate(
underscore,
'Formatters.underscore() is deprecated. Use this method as a top-level function instead.',
'Formatters.underscore() is deprecated. Import this method directly from discord.js instead.',
);

/**
Expand All @@ -365,11 +374,11 @@ class Formatters extends null {
* @memberof Formatters
* @param {Snowflake} userId The user id to format
* @returns {string}
* @deprecated Use this method as a top-level function instead.
* @deprecated Import this method directly from discord.js instead.
*/
static userMention = deprecate(
userMention,
'Formatters.userMention() is deprecated. Use this method as a top-level function instead.',
'Formatters.userMention() is deprecated. Import this method directly from discord.js instead.',
);
}

Expand Down
36 changes: 18 additions & 18 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2699,41 +2699,41 @@ export function createComponentBuilder<T extends keyof MappedComponentBuilderTyp
export function createComponentBuilder<C extends ComponentBuilder>(data: C): C;
export function createComponentBuilder(data: APIMessageComponent | ComponentBuilder): ComponentBuilder;

/** @deprecated This class is redundant as all methods of the class are top-level exports. */
/** @deprecated This class is redundant as all methods of the class can be imported from discord.js directly. */
export class Formatters extends null {
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static blockQuote: typeof blockQuote;
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static bold: typeof bold;
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static channelMention: typeof channelMention;
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static codeBlock: typeof codeBlock;
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static formatEmoji: typeof formatEmoji;
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static hideLinkEmbed: typeof hideLinkEmbed;
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static hyperlink: typeof hyperlink;
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static inlineCode: typeof inlineCode;
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static italic: typeof italic;
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static quote: typeof quote;
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static roleMention: typeof roleMention;
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static spoiler: typeof spoiler;
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static strikethrough: typeof strikethrough;
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static time: typeof time;
/** @deprecated Use this property as a top-level property instead. */
/** @deprecated Import this property directly from discord.js instead. */
public static TimestampStyles: typeof TimestampStyles;
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static underscore: typeof underscore;
/** @deprecated Use this method as a top-level function instead. */
/** @deprecated Import this method directly from discord.js instead. */
public static userMention: typeof userMention;
}

Expand Down

0 comments on commit 080622e

Please sign in to comment.