Skip to content

Commit

Permalink
feat: add subtext formatter (#10400)
Browse files Browse the repository at this point in the history
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
  • Loading branch information
sdanialraza and Jiralite committed Jul 24, 2024
1 parent b2970bb commit fcd35ea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/formatters/__tests__/formatters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
roleMention,
spoiler,
strikethrough,
subtext,
time,
TimestampStyles,
underline,
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions packages/formatters/src/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit fcd35ea

Please sign in to comment.