Skip to content

Formatters

classe · Source

Contains various Discord-specific functions for formatting messages.

Properties

TimestampStyles

static

TimestampStyles: Object<string, TimestampStylesString>

The message formatting timestamp styles supported by Discord. Source

Methods

blockQuote

static

blockQuote(content: string): string

Formats the content into a block quote. This needs to be at the start of the line for Discord to format it. Parameters

NameTypeDescription
contentstringThe content to wrap.

Returns: stringSource

bold

static

bold(content: string): string

Formats the content into bold text. Parameters

NameTypeDescription
contentstringThe content to wrap.

Returns: stringSource

channelMention

static

channelMention(channelId: string): string

Formats a channel id into a channel mention. Parameters

NameTypeDescription
channelIdstringThe channel id to format.

Returns: stringSource

chatInputApplicationCommandMention

static

chatInputApplicationCommandMention(commandName: string, subcommandGroupOrSubOrId: string | Snowflake, subcommandNameOrId?: string | Snowflake, commandId?: Snowflake): string

Formats an application command name, subcommand group name, subcommand name, and ID into an application command mention Parameters

NameTypeDescription
commandNamestringThe name of the application command
subcommandGroupOrSubOrIdstring | SnowflakeThe subcommand group name, subcommand name, or application command id
subcommandNameOrId?string | SnowflakeThe subcommand name or application command id
commandId?SnowflakeThe id of the application command

Returns: stringSource

codeBlock

static

codeBlock(contentOrLanguage: string, content?: string): string

Wraps the content inside a code block with an optional language. Parameters

NameTypeDescription
contentOrLanguagestringThe language to use, content if a second parameter isn't provided.
content?stringThe content to wrap.

Returns: stringSource

formatEmoji

static

formatEmoji(emojiId: string, animated?: boolean): string

Formats an emoji id into a fully qualified emoji identifier Parameters

NameTypeDescription
emojiIdstringThe emoji id to format.
animated?booleanWhether the emoji is animated or not. Defaults to false

Returns: stringSource

hideLinkEmbed

static

hideLinkEmbed(content: string): string

Wraps the URL into &lt;&gt;, which stops it from embedding. Parameters

NameTypeDescription
contentstringThe content to wrap.

Returns: stringSource

static

hyperlink(content: string, url: string, title?: string): string

Formats the content and the URL into a masked URL with an optional title. Parameters

NameTypeDescription
contentstringThe content to display.
urlstringThe URL the content links to.
title?stringThe title shown when hovering on the masked link.

Returns: stringSource

inlineCode

static

inlineCode(content: string): string

Wraps the content inside `backticks`, which formats it as inline code. Parameters

NameTypeDescription
contentstringThe content to wrap.

Returns: stringSource

italic

static

italic(content: string): string

Formats the content into italic text. Parameters

NameTypeDescription
contentstringThe content to wrap.

Returns: stringSource

quote

static

quote(content: string): string

Formats the content into a quote. This needs to be at the start of the line for Discord to format it. Parameters

NameTypeDescription
contentstringThe content to wrap.

Returns: stringSource

roleMention

static

roleMention(roleId: string): string

Formats a role id into a role mention. Parameters

NameTypeDescription
roleIdstringThe role id to format.

Returns: stringSource

spoiler

static

spoiler(content: string): string

Formats the content into spoiler text. Parameters

NameTypeDescription
contentstringThe content to spoiler.

Returns: stringSource

strikethrough

static

strikethrough(content: string): string

Formats the content into strike-through text. Parameters

NameTypeDescription
contentstringThe content to wrap.

Returns: stringSource

time

static

time(date?: number | Date, style?: TimestampStylesString): string

Formats a date into a short date-time string. Parameters

NameTypeDescription
date?number | DateThe date to format.
style?TimestampStylesStringThe style to use.

Returns: stringSource

underscore

static

underscore(content: string): string

Formats the content into underscored text. Parameters

NameTypeDescription
contentstringThe content to wrap.

Returns: stringSource

userMention

static

userMention(userId: string): string

Formats a user id into a user mention. Parameters

NameTypeDescription
userIdstringThe user id to format.

Returns: stringSource

Unofficial software. Not affiliated with or supported by Discord.