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/builders
Advanced tools
@discordjs/builders is a utility package for building and formatting Discord API interactions, such as commands and embeds, in a structured and type-safe manner. It is part of the larger discord.js library ecosystem.
Slash Command Builder
The Slash Command Builder allows you to create and structure slash commands for your Discord bot. This example creates a simple 'ping' command that replies with 'Pong!'.
const { SlashCommandBuilder } = require('@discordjs/builders');
const command = new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!');
console.log(command.toJSON());
Embed Builder
The Embed Builder helps you create rich embed messages with various properties like title, description, and color. This example creates a simple embed with a title, description, and green color.
const { EmbedBuilder } = require('@discordjs/builders');
const embed = new EmbedBuilder()
.setTitle('Sample Embed')
.setDescription('This is an example of an embed')
.setColor(0x00FF00);
console.log(embed.toJSON());
Button Builder
The Button Builder allows you to create interactive buttons for your Discord bot. This example creates a primary button with the label 'Click Me'.
const { ButtonBuilder, ButtonStyle } = require('@discordjs/builders');
const button = new ButtonBuilder()
.setCustomId('primary-button')
.setLabel('Click Me')
.setStyle(ButtonStyle.Primary);
console.log(button.toJSON());
Select Menu Builder
The Select Menu Builder helps you create dropdown menus for your Discord bot. This example creates a select menu with two options.
const { SelectMenuBuilder } = require('@discordjs/builders');
const selectMenu = new SelectMenuBuilder()
.setCustomId('select-menu')
.setPlaceholder('Choose an option')
.addOptions([
{ label: 'Option 1', value: 'option1' },
{ label: 'Option 2', value: 'option2' }
]);
console.log(selectMenu.toJSON());
discord.js is a powerful library for interacting with the Discord API. It provides a comprehensive set of features for building Discord bots, including message handling, event handling, and more. While @discordjs/builders focuses on building and formatting interactions, discord.js offers a broader range of functionalities for bot development.
Eris is another library for interacting with the Discord API. It is known for its performance and scalability, making it suitable for large bots. Eris provides similar functionalities to discord.js but with a different design philosophy. It does not have a dedicated builders package like @discordjs/builders, but it offers similar capabilities through its core library.
discord-interactions is a library specifically designed for handling Discord interactions, such as slash commands and buttons. It provides utilities for validating and responding to interactions. While it offers similar functionalities to @discordjs/builders, it is more focused on the interaction aspect and does not provide the same level of integration with the broader Discord API.
@discordjs/builders
is a utility package for easily building Discord API payloads.
Node.js 18 or newer is required.
npm install @discordjs/builders
yarn add @discordjs/builders
pnpm add @discordjs/builders
You can find examples of how to use the builders in the Slash Command Builders examples.
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 builders that you can use when creating your bot
The npm package @discordjs/builders receives a total of 95,860 weekly downloads. As such, @discordjs/builders popularity was classified as popular.
We found that @discordjs/builders 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.