Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@discordjs/formatters
Advanced tools
@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
is a collection of functions for formatting strings to be used on Discord.
Node.js 18 or newer is required.
npm install @discordjs/formatters
yarn add @discordjs/formatters
pnpm add @discordjs/formatters
bun 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.
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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.