Formatters
classe · Source
Contains various Discord-specific functions for formatting messages.
Properties
TimestampStyles
The message formatting timestamp styles supported by Discord. Source
Methods
blockQuote
Formats the content into a block quote. This needs to be at the start of the line for Discord to format it. Parameters
| Name | Type | Description |
|---|---|---|
content | string | The content to wrap. |
Returns: stringSource
bold
Formats the content into bold text. Parameters
| Name | Type | Description |
|---|---|---|
content | string | The content to wrap. |
Returns: stringSource
channelMention
Formats a channel id into a channel mention. Parameters
| Name | Type | Description |
|---|---|---|
channelId | string | The channel id to format. |
Returns: stringSource
chatInputApplicationCommandMention
Formats an application command name, subcommand group name, subcommand name, and ID into an application command mention Parameters
| Name | Type | Description |
|---|---|---|
commandName | string | The name of the application command |
subcommandGroupOrSubOrId | string | Snowflake | The subcommand group name, subcommand name, or application command id |
subcommandNameOrId? | string | Snowflake | The subcommand name or application command id |
commandId? | Snowflake | The id of the application command |
Returns: stringSource
codeBlock
Wraps the content inside a code block with an optional language. Parameters
| Name | Type | Description |
|---|---|---|
contentOrLanguage | string | The language to use, content if a second parameter isn't provided. |
content? | string | The content to wrap. |
Returns: stringSource
formatEmoji
Formats an emoji id into a fully qualified emoji identifier Parameters
| Name | Type | Description |
|---|---|---|
emojiId | string | The emoji id to format. |
animated? | boolean | Whether the emoji is animated or not. Defaults to false |
Returns: stringSource
hideLinkEmbed
Wraps the URL into <>, which stops it from embedding. Parameters
| Name | Type | Description |
|---|---|---|
content | string | The content to wrap. |
Returns: stringSource
hyperlink
Formats the content and the URL into a masked URL with an optional title. Parameters
| Name | Type | Description |
|---|---|---|
content | string | The content to display. |
url | string | The URL the content links to. |
title? | string | The title shown when hovering on the masked link. |
Returns: stringSource
inlineCode
Wraps the content inside `backticks`, which formats it as inline code. Parameters
| Name | Type | Description |
|---|---|---|
content | string | The content to wrap. |
Returns: stringSource
italic
Formats the content into italic text. Parameters
| Name | Type | Description |
|---|---|---|
content | string | The content to wrap. |
Returns: stringSource
quote
Formats the content into a quote. This needs to be at the start of the line for Discord to format it. Parameters
| Name | Type | Description |
|---|---|---|
content | string | The content to wrap. |
Returns: stringSource
roleMention
Formats a role id into a role mention. Parameters
| Name | Type | Description |
|---|---|---|
roleId | string | The role id to format. |
Returns: stringSource
spoiler
Formats the content into spoiler text. Parameters
| Name | Type | Description |
|---|---|---|
content | string | The content to spoiler. |
Returns: stringSource
strikethrough
Formats the content into strike-through text. Parameters
| Name | Type | Description |
|---|---|---|
content | string | The content to wrap. |
Returns: stringSource
time
Formats a date into a short date-time string. Parameters
| Name | Type | Description |
|---|---|---|
date? | number | Date | The date to format. |
style? | TimestampStylesString | The style to use. |
Returns: stringSource
underscore
Formats the content into underscored text. Parameters
| Name | Type | Description |
|---|---|---|
content | string | The content to wrap. |
Returns: stringSource
userMention
Formats a user id into a user mention. Parameters
| Name | Type | Description |
|---|---|---|
userId | string | The user id to format. |
Returns: stringSource