v2componentsbuilder
Version:
A discord.js v2components builder
48 lines (34 loc) • 2.79 kB
Markdown
# V2 Discord Message Component Builders for Discord.js
This repository contains TypeScript builders for crafting **Discord Message Components** with full type safety, clean structure, and reusable patterns.
It wraps raw Discord API component structures into easy-to-use, chainable builders designed for use in bots, utilities, or frameworks.
> 🔗 Reference: [Discord Developer Docs – Message Components](https://discord.com/developers/docs/components/reference)
> 🔗 Support/Hangout Discord: [Golden Development](https://discord.goldendev.net)
> 🔗 My YouTube Channel: [Golden Development](https://youtube.goldendev.net)
> 🔗 My Discord Bot: [Golden Bot](https://goldenbot.net)
---
## 🧱 Included Builders
Each builder corresponds to a Discord component type, with smart defaults, validation, and clear APIs.
| Component | Builder Class | Description |
|---------------------|------------------------------|-------------|
| Button | `ButtonBuilder` | Build styled, interactive buttons with labels, emojis, custom IDs, and URLs. |
| String Select | `StringSelectBuilder` | Create menus with up to 25 options using custom labels, values, emojis, etc. |
| User Select | `UserSelectBuilder` | Select one or more users from the server dynamically. |
| Role Select | `RoleSelectBuilder` | Let users choose one or more server roles. |
| Mentionable Select | `MentionableSelectBuilder` | Select users or roles with a unified component. |
| Channel Select | `ChannelSelectBuilder` | Choose from specific types of server channels (text, voice, etc.). |
| Action Row | `ActionRowBuilder` | Compose select menus or buttons into Discord action rows. |
| Container | `ContainerBuilder` | A utility for grouping components together. |
| Media Gallery | `MediaGallery` | Utility to bundle media content. |
| Section / Separator | `SectionBuilder`, `Separator`| Display structured sections and dividers. |
| File & Thumbnail | `File`, `Thumbnail` | Attach files or images. |
| Text Displays | `TextDisplay` | Render text blocks inside components. |
---
## 📦 Installation
Clone or copy this directory into your bot or utility project. It is framework-agnostic and works with any method that sends raw Discord payloads (e.g., REST, Interactions API, libraries like `discord.js`, `harmony`, etc.). Originally designed to be used with discord.js.
```ts
import { V2ComponentBuilder, V2TextDisplayBuilder } from 'v2componentsbuilder';
const components = new V2ComponentBuilder().addComponents([
new V2TextDisplayBuilder("Testing"),
]);
sendMessage(components.toJSON());
```