discord-components-v2-helper
v0.2.0
Published
Helpers for componentsV2 from Discord.js V14+
Readme
discord-components-v2-helper
Helpers for Discord.js ComponentsV2 (v14+).
Easily build Discord message components with a simple, type-safe API.
Features
- Type-safe helpers for all major Discord ComponentsV2 builders
- Simple, composable functions for building complex UIs
- Written in TypeScript
Installation
npm install discord-components-v2-helperRequires
discord.js@^14.22.1as a peer dependency.
Usage
import {
Button,
Container,
Media,
Section,
Separator,
StringSelector,
Text,
Thumbnail,
} from "discord-components-v2-helper"
// Example: Create a button
const myButton = Button({
customId: "my_button",
label: "Click me!",
style: ButtonStyle.Primary,
})
// Example: Create a section with text and a button
const mySection = Section({
textcomponents: [Text("Hello, world!")],
buttonAccessory: myButton,
})
// Example: Create a container with components
const myContainer = Container({
components: [mySection, Separator("medium")],
accentColor: [0, 255, 0],
})Components
Button(props): Create a Discord button.Container(props): Compose multiple components into a container.Media(props): Add media galleries.Section(props): Create a section with text, button, and/or thumbnail.Separator(props): Add a separator with spacing.StringSelector(props): Create a string select menu.Text(props): Create a text display.Thumbnail(props): Add a thumbnail.
See src/types.ts for detailed prop types.
License
This project is licensed under the MIT License
