mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 18:13:29 +01:00
feat: add subtext formatter (#10400)
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
|||||||
roleMention,
|
roleMention,
|
||||||
spoiler,
|
spoiler,
|
||||||
strikethrough,
|
strikethrough,
|
||||||
|
subtext,
|
||||||
time,
|
time,
|
||||||
TimestampStyles,
|
TimestampStyles,
|
||||||
underline,
|
underline,
|
||||||
@@ -277,6 +278,12 @@ describe('Message formatters', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('subtext', () => {
|
||||||
|
test('GIVEN "discord.js" THEN returns "-# discord.js"', () => {
|
||||||
|
expect<'-# discord.js'>(subtext('discord.js')).toEqual('-# discord.js');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('time', () => {
|
describe('time', () => {
|
||||||
test('GIVEN no arguments THEN returns "<t:${bigint}>"', () => {
|
test('GIVEN no arguments THEN returns "<t:${bigint}>"', () => {
|
||||||
vitest.useFakeTimers();
|
vitest.useFakeTimers();
|
||||||
|
|||||||
@@ -569,6 +569,16 @@ export function unorderedList(list: RecursiveArray<string>): string {
|
|||||||
return listCallback(list);
|
return listCallback(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the content into a subtext.
|
||||||
|
*
|
||||||
|
* @typeParam Content - This is inferred by the supplied content
|
||||||
|
* @param content - The content to wrap
|
||||||
|
*/
|
||||||
|
export function subtext<Content extends string>(content: Content): `-# ${Content}` {
|
||||||
|
return `-# ${content}`;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats a date into a short date-time string.
|
* Formats a date into a short date-time string.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user