diff --git a/apps/guide/src/content/04-popular-topics/04-formatters.mdx b/apps/guide/src/content/04-popular-topics/04-formatters.mdx new file mode 100644 index 000000000..3af5ab818 --- /dev/null +++ b/apps/guide/src/content/04-popular-topics/04-formatters.mdx @@ -0,0 +1,95 @@ +--- +title: Formatters +category: Popular topics +--- + +# Formatters + +discord.js provides the package which contains a variety of utilities you can use when writing your Discord bot. + +## Basic Markdown + +These functions format strings into all the different markdown styles supported by Discord. + + + +```js +import { bold, italic, strikethrough, underscore, spoiler, quote, blockQuote } from 'discord.js'; + +const string = 'Hello!'; +const boldString = bold(string); +const italicString = italic(string); +const strikethroughString = strikethrough(string); +const underscoreString = underscore(string); +const spoilerString = spoiler(string); +const quoteString = quote(string); +const blockquoteString = blockQuote(string); +``` + + + +## Links + +There are also two functions to format hyperlinks. _`hyperlink()`_ will format the URL into a masked markdown link, and _`hideLinkEmbed()`_ will wrap the URL in _`<>`_, preventing it from embedding. + + + +```js +import { hyperlink, hideLinkEmbed } from 'discord.js'; + +const url = 'https://discord.js.org/'; +const link = hyperlink('discord.js', url); +const hiddenEmbed = hideLinkEmbed(url); +``` + + + +## Code blocks + +You can use _`inlineCode()`_ and _`codeBlock()`_ to turn a string into an inline code block or a regular code block with or without syntax highlighting. + + + +```js +import { inlineCode, codeBlock } from 'discord.js'; + +const jsString = 'const value = true;'; +const inline = inlineCode(jsString); +const codeblock = codeBlock(jsString); +const highlighted = codeBlock('js', jsString); +``` + + + +## Timestamps + +With _`time()`_, you can format Unix timestamps and dates into a Discord time string. + + + +```js +import { time, TimestampStyles } from 'discord.js'; + +const date = new Date(); +const timeString = time(date); +const relative = time(date, TimestampStyles.RelativeTime); +``` + + + +## Mentions + +_`userMention()`_, _`channelMention()`_, and _`roleMention()`_ all exist to format Snowflakes into mentions. + + + +```js +import { channelMention, roleMention, userMention } from 'discord.js'; + +const id = '123456789012345678'; +const channel = channelMention(id); +const role = roleMention(id); +const user = userMention(id); +``` + + diff --git a/apps/guide/src/content/04-popular-topics/04-threads.mdx b/apps/guide/src/content/04-popular-topics/05-threads.mdx similarity index 100% rename from apps/guide/src/content/04-popular-topics/04-threads.mdx rename to apps/guide/src/content/04-popular-topics/05-threads.mdx diff --git a/apps/guide/src/content/04-popular-topics/05-webhooks.mdx b/apps/guide/src/content/04-popular-topics/06-webhooks.mdx similarity index 100% rename from apps/guide/src/content/04-popular-topics/05-webhooks.mdx rename to apps/guide/src/content/04-popular-topics/06-webhooks.mdx