mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(Utils): add additional formatters (#6388)
This commit is contained in:
14
package-lock.json
generated
14
package-lock.json
generated
@@ -8,7 +8,7 @@
|
|||||||
"version": "13.1.0-dev",
|
"version": "13.1.0-dev",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/builders": "^0.4.0",
|
"@discordjs/builders": "^0.5.0",
|
||||||
"@discordjs/collection": "^0.2.1",
|
"@discordjs/collection": "^0.2.1",
|
||||||
"@discordjs/form-data": "^3.0.1",
|
"@discordjs/form-data": "^3.0.1",
|
||||||
"@sapphire/async-queue": "^1.1.4",
|
"@sapphire/async-queue": "^1.1.4",
|
||||||
@@ -1006,9 +1006,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@discordjs/builders": {
|
"node_modules/@discordjs/builders": {
|
||||||
"version": "0.4.0",
|
"version": "0.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.5.0.tgz",
|
||||||
"integrity": "sha512-EiwLltKph6TSaPJIzJYdzNc1PnA2ZNaaE0t0ODg3ghnpVHqfgd0YX9/srsleYHW2cw1sfIq+kbM+h0etf7GWLA==",
|
"integrity": "sha512-HP5y4Rqw68o61Qv4qM5tVmDbWi4mdTFftqIOGRo33SNPpLJ1Ga3KEIR2ibKofkmsoQhEpLmopD1AZDs3cKpHuw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sindresorhus/is": "^4.0.1",
|
"@sindresorhus/is": "^4.0.1",
|
||||||
"discord-api-types": "^0.22.0",
|
"discord-api-types": "^0.22.0",
|
||||||
@@ -12322,9 +12322,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@discordjs/builders": {
|
"@discordjs/builders": {
|
||||||
"version": "0.4.0",
|
"version": "0.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.5.0.tgz",
|
||||||
"integrity": "sha512-EiwLltKph6TSaPJIzJYdzNc1PnA2ZNaaE0t0ODg3ghnpVHqfgd0YX9/srsleYHW2cw1sfIq+kbM+h0etf7GWLA==",
|
"integrity": "sha512-HP5y4Rqw68o61Qv4qM5tVmDbWi4mdTFftqIOGRo33SNPpLJ1Ga3KEIR2ibKofkmsoQhEpLmopD1AZDs3cKpHuw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@sindresorhus/is": "^4.0.1",
|
"@sindresorhus/is": "^4.0.1",
|
||||||
"discord-api-types": "^0.22.0",
|
"discord-api-types": "^0.22.0",
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/discordjs/discord.js#readme",
|
"homepage": "https://github.com/discordjs/discord.js#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/builders": "^0.4.0",
|
"@discordjs/builders": "^0.5.0",
|
||||||
"@discordjs/collection": "^0.2.1",
|
"@discordjs/collection": "^0.2.1",
|
||||||
"@discordjs/form-data": "^3.0.1",
|
"@discordjs/form-data": "^3.0.1",
|
||||||
"@sapphire/async-queue": "^1.1.4",
|
"@sapphire/async-queue": "^1.1.4",
|
||||||
|
|||||||
@@ -3,17 +3,22 @@
|
|||||||
const {
|
const {
|
||||||
blockQuote,
|
blockQuote,
|
||||||
bold,
|
bold,
|
||||||
|
channelMention,
|
||||||
codeBlock,
|
codeBlock,
|
||||||
|
formatEmoji,
|
||||||
hideLinkEmbed,
|
hideLinkEmbed,
|
||||||
hyperlink,
|
hyperlink,
|
||||||
inlineCode,
|
inlineCode,
|
||||||
italic,
|
italic,
|
||||||
|
memberNicknameMention,
|
||||||
quote,
|
quote,
|
||||||
|
roleMention,
|
||||||
|
spoiler,
|
||||||
strikethrough,
|
strikethrough,
|
||||||
time,
|
time,
|
||||||
TimestampStyles,
|
TimestampStyles,
|
||||||
underscore,
|
underscore,
|
||||||
spoiler,
|
userMention,
|
||||||
} = require('@discordjs/builders');
|
} = require('@discordjs/builders');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,6 +44,15 @@ Formatters.blockQuote = blockQuote;
|
|||||||
*/
|
*/
|
||||||
Formatters.bold = bold;
|
Formatters.bold = bold;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats a channel ID into a channel mention.
|
||||||
|
* @method channelMention
|
||||||
|
* @memberof Formatters
|
||||||
|
* @param {string} channelId The channel ID to format.
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
Formatters.channelMention = channelMention;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps the content inside a codeblock with an optional language.
|
* Wraps the content inside a codeblock with an optional language.
|
||||||
* @method codeBlock
|
* @method codeBlock
|
||||||
@@ -50,7 +64,17 @@ Formatters.bold = bold;
|
|||||||
Formatters.codeBlock = codeBlock;
|
Formatters.codeBlock = codeBlock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats the URL into <>, which stops it from embedding.
|
* 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] Whether the emoji is animated or not. Defaults to `false`
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
Formatters.formatEmoji = formatEmoji;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps the URL into `<>`, which stops it from embedding.
|
||||||
* @method hideLinkEmbed
|
* @method hideLinkEmbed
|
||||||
* @memberof Formatters
|
* @memberof Formatters
|
||||||
* @param {string} content The content to wrap.
|
* @param {string} content The content to wrap.
|
||||||
@@ -70,7 +94,7 @@ Formatters.hideLinkEmbed = hideLinkEmbed;
|
|||||||
Formatters.hyperlink = hyperlink;
|
Formatters.hyperlink = hyperlink;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps the content inside an inline code.
|
* Wraps the content inside \`backticks\`, which formats it as inline code.
|
||||||
* @method inlineCode
|
* @method inlineCode
|
||||||
* @memberof Formatters
|
* @memberof Formatters
|
||||||
* @param {string} content The content to wrap.
|
* @param {string} content The content to wrap.
|
||||||
@@ -87,6 +111,15 @@ Formatters.inlineCode = inlineCode;
|
|||||||
*/
|
*/
|
||||||
Formatters.italic = italic;
|
Formatters.italic = italic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats a user ID into a member-nickname mention.
|
||||||
|
* @method memberNicknameMention
|
||||||
|
* @memberof Formatters
|
||||||
|
* @param {string} memberId The user ID to format.
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
Formatters.memberNicknameMention = memberNicknameMention;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats the content into a quote. This needs to be at the start of the line for Discord to format it.
|
* Formats the content into a quote. This needs to be at the start of the line for Discord to format it.
|
||||||
* @method quote
|
* @method quote
|
||||||
@@ -97,7 +130,25 @@ Formatters.italic = italic;
|
|||||||
Formatters.quote = quote;
|
Formatters.quote = quote;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats the content into strikethrough text.
|
* Formats a role ID into a role mention.
|
||||||
|
* @method roleMention
|
||||||
|
* @memberof Formatters
|
||||||
|
* @param {string} roleId The role ID to format.
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
Formatters.roleMention = roleMention;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the content into spoiler text.
|
||||||
|
* @method spoiler
|
||||||
|
* @memberof Formatters
|
||||||
|
* @param {string} content The content to spoiler.
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
Formatters.spoiler = spoiler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the content into strike-through text.
|
||||||
* @method strikethrough
|
* @method strikethrough
|
||||||
* @memberof Formatters
|
* @memberof Formatters
|
||||||
* @param {string} content The content to wrap.
|
* @param {string} content The content to wrap.
|
||||||
@@ -146,12 +197,12 @@ Formatters.TimestampStyles = TimestampStyles;
|
|||||||
Formatters.underscore = underscore;
|
Formatters.underscore = underscore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats the content into spoiler text.
|
* Formats a user ID into a user mention.
|
||||||
* @method spoiler
|
* @method userMention
|
||||||
* @memberof Formatters
|
* @memberof Formatters
|
||||||
* @param {string} content The content to spoiler.
|
* @param {string} userId The user ID to format.
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
Formatters.spoiler = spoiler;
|
Formatters.userMention = userMention;
|
||||||
|
|
||||||
module.exports = Formatters;
|
module.exports = Formatters;
|
||||||
|
|||||||
16
typings/index.d.ts
vendored
16
typings/index.d.ts
vendored
@@ -1,18 +1,23 @@
|
|||||||
import {
|
import {
|
||||||
blockQuote,
|
blockQuote,
|
||||||
bold,
|
bold,
|
||||||
|
channelMention,
|
||||||
codeBlock,
|
codeBlock,
|
||||||
|
formatEmoji,
|
||||||
hideLinkEmbed,
|
hideLinkEmbed,
|
||||||
hyperlink,
|
hyperlink,
|
||||||
inlineCode,
|
inlineCode,
|
||||||
italic,
|
italic,
|
||||||
|
memberNicknameMention,
|
||||||
quote,
|
quote,
|
||||||
|
roleMention,
|
||||||
|
spoiler,
|
||||||
strikethrough,
|
strikethrough,
|
||||||
time,
|
time,
|
||||||
TimestampStyles,
|
TimestampStyles,
|
||||||
TimestampStylesString,
|
TimestampStylesString,
|
||||||
underscore,
|
underscore,
|
||||||
spoiler,
|
userMention,
|
||||||
} from '@discordjs/builders';
|
} from '@discordjs/builders';
|
||||||
import { Collection } from '@discordjs/collection';
|
import { Collection } from '@discordjs/collection';
|
||||||
import { ChildProcess } from 'child_process';
|
import { ChildProcess } from 'child_process';
|
||||||
@@ -125,7 +130,7 @@ import {
|
|||||||
RawWelcomeChannelData,
|
RawWelcomeChannelData,
|
||||||
RawWelcomeScreenData,
|
RawWelcomeScreenData,
|
||||||
RawWidgetData,
|
RawWidgetData,
|
||||||
RawWidgetMemberData,
|
RawWidgetMemberData
|
||||||
} from './rawDataTypes';
|
} from './rawDataTypes';
|
||||||
|
|
||||||
//#region Classes
|
//#region Classes
|
||||||
@@ -1912,18 +1917,23 @@ export class Util extends null {
|
|||||||
export class Formatters extends null {
|
export class Formatters extends null {
|
||||||
public static blockQuote: typeof blockQuote;
|
public static blockQuote: typeof blockQuote;
|
||||||
public static bold: typeof bold;
|
public static bold: typeof bold;
|
||||||
|
public static channelMention: typeof channelMention;
|
||||||
public static codeBlock: typeof codeBlock;
|
public static codeBlock: typeof codeBlock;
|
||||||
|
public static formatEmoji: typeof formatEmoji;
|
||||||
public static hideLinkEmbed: typeof hideLinkEmbed;
|
public static hideLinkEmbed: typeof hideLinkEmbed;
|
||||||
public static hyperlink: typeof hyperlink;
|
public static hyperlink: typeof hyperlink;
|
||||||
public static inlineCode: typeof inlineCode;
|
public static inlineCode: typeof inlineCode;
|
||||||
public static italic: typeof italic;
|
public static italic: typeof italic;
|
||||||
|
public static memberNicknameMention: typeof memberNicknameMention;
|
||||||
public static quote: typeof quote;
|
public static quote: typeof quote;
|
||||||
|
public static roleMention: typeof roleMention;
|
||||||
|
public static spoiler: typeof spoiler;
|
||||||
public static strikethrough: typeof strikethrough;
|
public static strikethrough: typeof strikethrough;
|
||||||
public static time: typeof time;
|
public static time: typeof time;
|
||||||
public static TimestampStyles: typeof TimestampStyles;
|
public static TimestampStyles: typeof TimestampStyles;
|
||||||
public static TimestampStylesString: TimestampStylesString;
|
public static TimestampStylesString: TimestampStylesString;
|
||||||
public static underscore: typeof underscore;
|
public static underscore: typeof underscore;
|
||||||
public static spoiler: typeof spoiler;
|
public static userMention: typeof userMention;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class VoiceChannel extends BaseGuildVoiceChannel {
|
export class VoiceChannel extends BaseGuildVoiceChannel {
|
||||||
|
|||||||
Reference in New Issue
Block a user