feat: add subtext formatter (#10400)

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
Danial Raza
2024-07-24 12:23:55 +02:00
committed by GitHub
parent b2970bb2dd
commit fcd35ea2e7
2 changed files with 17 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ import {
roleMention,
spoiler,
strikethrough,
subtext,
time,
TimestampStyles,
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', () => {
test('GIVEN no arguments THEN returns "<t:${bigint}>"', () => {
vitest.useFakeTimers();

View File

@@ -569,6 +569,16 @@ export function unorderedList(list: RecursiveArray<string>): string {
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.
*