diff --git a/src/messages/formatters.ts b/src/messages/formatters.ts index 898f03d8..41c49678 100644 --- a/src/messages/formatters.ts +++ b/src/messages/formatters.ts @@ -146,6 +146,15 @@ export function hyperlink(content: string, url: string | URL, title?: string) { return title ? `[${content}](${url} "${title}")` : `[${content}](${url})`; } +/** + * Wraps the content inside spoiler (hidden text). + * @param content The content to wrap. + * @returns The formatted content. + */ +export function spoiler(content: C): `||${C}||` { + return `||${content}||`; +} + /** * Formats the user ID into a user mention. * @param userId The user ID to format. diff --git a/tests/messages.test.ts b/tests/messages.test.ts index b582b549..93391a43 100644 --- a/tests/messages.test.ts +++ b/tests/messages.test.ts @@ -6,6 +6,7 @@ import { Faces, hideLinkEmbed, hyperlink, + spoiler, inlineCode, italic, memberNicknameMention, @@ -106,6 +107,12 @@ describe('Messages', () => { ).toBe('[discord.js](https://discord.js.org/ "Official Documentation")'); }); }); + + describe('spoiler', () => { + test('GIVEN "discord.js" THEN returns "||discord.js||"', () => { + expect<'||discord.js||'>(spoiler('discord.js')).toBe('||discord.js||'); + }); + }); describe('Mentions', () => { describe('userMention', () => {