Skip to content

Commit

Permalink
refactor(Formatters): deprecate methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiralite committed Jul 27, 2022
1 parent 46ca77a commit 1a88564
Showing 1 changed file with 56 additions and 16 deletions.
72 changes: 56 additions & 16 deletions packages/discord.js/src/util/Formatters.js
@@ -1,5 +1,6 @@
'use strict';

const { deprecate } = require('node:util');
const {
blockQuote,
bold,
Expand Down Expand Up @@ -166,7 +167,10 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static blockQuote = blockQuote;
static blockQuote = deprecate(
blockQuote,
'Formatters.blockQuote() is deprecated. Use this method as a top-level function instead.',
);

/**
* Formats the content into bold text.
Expand All @@ -176,7 +180,7 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static bold = bold;
static bold = deprecate(bold, 'Formatters.bold() is deprecated. Use this method as a top-level function instead.');

/**
* Formats a channel id into a channel mention.
Expand All @@ -186,7 +190,10 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static channelMention = channelMention;
static channelMention = deprecate(
channelMention,
'Formatters.channelMention() is deprecated. Use this method as a top-level function instead.',
);

/**
* Wraps the content inside a code block with an optional language.
Expand All @@ -197,7 +204,10 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static codeBlock = codeBlock;
static codeBlock = deprecate(
codeBlock,
'Formatters.codeBlock() is deprecated. Use this method as a top-level function instead.',
);

/**
* Formats an emoji id into a fully qualified emoji identifier.
Expand All @@ -208,7 +218,10 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static formatEmoji = formatEmoji;
static formatEmoji = deprecate(
formatEmoji,
'Formatters.formatEmoji() is deprecated. Use this method as a top-level function instead.',
);

/**
* Wraps the URL into `<>`, which stops it from embedding.
Expand All @@ -218,7 +231,10 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static hideLinkEmbed = hideLinkEmbed;
static hideLinkEmbed = deprecate(
hideLinkEmbed,
'Formatters.hideLinkEmbed() is deprecated. Use this method as a top-level function instead.',
);

/**
* Formats the content and the URL into a masked URL with an optional title.
Expand All @@ -230,7 +246,10 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static hyperlink = hyperlink;
static hyperlink = deprecate(
hyperlink,
'Formatters.hyperlink() is deprecated. Use this method as a top-level function instead.',
);

/**
* Wraps the content inside \`backticks\`, which formats it as inline code.
Expand All @@ -240,7 +259,10 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static inlineCode = inlineCode;
static inlineCode = deprecate(
inlineCode,
'Formatters.inlineCode() is deprecated. Use this method as a top-level function instead.',
);

/**
* Formats the content into italic text.
Expand All @@ -250,7 +272,10 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static italic = italic;
static italic = deprecate(
italic,
'Formatters.italic() is deprecated. Use this method as a top-level function instead.',
);

/**
* Formats the content into a quote. This needs to be at the start of the line for Discord to format it.
Expand All @@ -260,7 +285,7 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static quote = quote;
static quote = deprecate(quote, 'Formatters.quote() is deprecated. Use this method as a top-level function instead.');

/**
* Formats a role id into a role mention.
Expand All @@ -270,7 +295,10 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static roleMention = roleMention;
static roleMention = deprecate(
roleMention,
'Formatters.roleMention() is deprecated. Use this method as a top-level function instead.',
);

/**
* Formats the content into spoiler text.
Expand All @@ -280,7 +308,10 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static spoiler = spoiler;
static spoiler = deprecate(
spoiler,
'Formatters.spoiler() is deprecated. Use this method as a top-level function instead.',
);

/**
* Formats the content into strike-through text.
Expand All @@ -290,7 +321,10 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static strikethrough = strikethrough;
static strikethrough = deprecate(
strikethrough,
'Formatters.strikethrough() is deprecated. Use this method as a top-level function instead.',
);

/**
* Formats a date into a short date-time string.
Expand All @@ -301,7 +335,7 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static time = time;
static time = deprecate(time, 'Formatters.time() is deprecated. Use this method as a top-level function instead.');

/**
* The message formatting timestamp
Expand All @@ -320,7 +354,10 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static underscore = underscore;
static underscore = deprecate(
underscore,
'Formatters.underscore() is deprecated. Use this method as a top-level function instead.',
);

/**
* Formats a user id into a user mention.
Expand All @@ -330,7 +367,10 @@ class Formatters extends null {
* @returns {string}
* @deprecated Use this method as a top-level function instead.
*/
static userMention = userMention;
static userMention = deprecate(
userMention,
'Formatters.userMention() is deprecated. Use this method as a top-level function instead.',
);
}

module.exports = Formatters;

0 comments on commit 1a88564

Please sign in to comment.