Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@discordjs/formatters
Advanced tools
A set of functions to format strings for Discord.
@discordjs/formatters is a utility package designed to help format messages and other content for Discord bots. It provides a set of functions to easily format text in a way that is compatible with Discord's markdown and other formatting features.
Code Block Formatting
This feature allows you to format text as a code block in Discord. The `codeBlock` function takes two arguments: the language for syntax highlighting and the code itself.
const { codeBlock } = require('@discordjs/formatters');
const formattedCode = codeBlock('js', 'const x = 10;');
console.log(formattedCode);
Inline Code Formatting
This feature allows you to format text as inline code in Discord. The `inlineCode` function takes a single argument: the code to be formatted.
const { inlineCode } = require('@discordjs/formatters');
const formattedInlineCode = inlineCode('const x = 10;');
console.log(formattedInlineCode);
Quote Formatting
This feature allows you to format text as a quote in Discord. The `quote` function takes a single argument: the text to be quoted.
const { quote } = require('@discordjs/formatters');
const formattedQuote = quote('This is a quoted text.');
console.log(formattedQuote);
Bold Text Formatting
This feature allows you to format text as bold in Discord. The `bold` function takes a single argument: the text to be formatted in bold.
const { bold } = require('@discordjs/formatters');
const formattedBoldText = bold('This is bold text.');
console.log(formattedBoldText);
Italic Text Formatting
This feature allows you to format text as italic in Discord. The `italic` function takes a single argument: the text to be formatted in italic.
const { italic } = require('@discordjs/formatters');
const formattedItalicText = italic('This is italic text.');
console.log(formattedItalicText);
discord.js is a powerful library for interacting with the Discord API. While it is more comprehensive and includes features for creating and managing bots, it also includes some basic formatting utilities. However, it is not as specialized in formatting as @discordjs/formatters.
discord-markdown is a package that parses and renders Discord-flavored markdown. It is useful for converting markdown to HTML or other formats, but it does not provide the same level of utility functions for formatting text directly as @discordjs/formatters.
markdown-it is a markdown parser that can be extended with plugins to support various markdown features, including those used by Discord. While it is highly customizable and powerful, it is not specifically tailored for Discord's formatting needs like @discordjs/formatters.
@discordjs/formatters
set of functions to format strings for Discord.
Node.js 16.9.0 or newer is required.
npm install @discordjs/formatters
yarn add @discordjs/formatters
pnpm add @discordjs/formatters
import { codeBlock } from '@discordjs/formatters';
const formattedCode = codeBlock('hello world!');
console.log(formattedCode);
// Prints:
// ```
// hello world!
// ```
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
documentation.
See the contribution guide if you'd like to submit a PR.
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official discord.js Server.
FAQs
A set of functions to format strings for Discord.
The npm package @discordjs/formatters receives a total of 137,076 weekly downloads. As such, @discordjs/formatters popularity was classified as popular.
We found that @discordjs/formatters demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.