Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@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
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.
The npm package @discordjs/formatters receives a total of 167,401 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 0 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.