diff --git a/packages/builders/__tests__/messages/formatters.test.ts b/packages/builders/__tests__/messages/formatters.test.ts index 151b5aa9bdc2..febe7c4e3f95 100644 --- a/packages/builders/__tests__/messages/formatters.test.ts +++ b/packages/builders/__tests__/messages/formatters.test.ts @@ -24,11 +24,11 @@ import { describe('Message formatters', () => { describe('codeBlock', () => { test('GIVEN "discord.js" with no language THEN returns "```\\ndiscord.js```"', () => { - expect<'```\ndiscord.js```'>(codeBlock('discord.js')).toEqual('```\ndiscord.js```'); + expect<'```\ndiscord.js\n```'>(codeBlock('discord.js')).toEqual('```\ndiscord.js\n```'); }); test('GIVEN "discord.js" with "js" as language THEN returns "```js\\ndiscord.js```"', () => { - expect<'```js\ndiscord.js```'>(codeBlock('js', 'discord.js')).toEqual('```js\ndiscord.js```'); + expect<'```js\ndiscord.js\n```'>(codeBlock('js', 'discord.js')).toEqual('```js\ndiscord.js\n```'); }); }); diff --git a/packages/builders/src/messages/formatters.ts b/packages/builders/src/messages/formatters.ts index 4b3b3fdad934..73f0b024b9b4 100644 --- a/packages/builders/src/messages/formatters.ts +++ b/packages/builders/src/messages/formatters.ts @@ -6,7 +6,7 @@ import type { Snowflake } from 'discord-api-types/globals'; * * @param content - The content to wrap */ -export function codeBlock(content: C): `\`\`\`\n${C}\`\`\``; +export function codeBlock(content: C): `\`\`\`\n${C}\n\`\`\``; /** * Wraps the content inside a codeblock with the specified language @@ -14,9 +14,9 @@ export function codeBlock(content: C): `\`\`\`\n${C}\`\`\``; * @param language - The language for the codeblock * @param content - The content to wrap */ -export function codeBlock(language: L, content: C): `\`\`\`${L}\n${C}\`\`\``; +export function codeBlock(language: L, content: C): `\`\`\`${L}\n${C}\n\`\`\``; export function codeBlock(language: string, content?: string): string { - return typeof content === 'undefined' ? `\`\`\`\n${language}\`\`\`` : `\`\`\`${language}\n${content}\`\`\``; + return typeof content === 'undefined' ? `\`\`\`\n${language}\n\`\`\`` : `\`\`\`${language}\n${content}\n\`\`\``; } /**