cordix-builders
v1.0.0
Published
A modern toolkit for building structured and interactive Discord message components using Cordix.
Maintainers
Readme
cordix-builders 🧩
cordix-builders is a modern toolkit for building advanced and structured Discord message components with ease. Designed for use with the Cordix library, it provides a clean, chainable API to create embeds, buttons, select menus, modals, and more — all fully compatible with the Discord API.
Features
- EmbedBuilder: Easily construct Discord embeds with chainable methods.
- ButtonBuilder: Create interactive buttons with custom labels, styles, and actions.
- ActionRowBuilder: Group components (buttons, menus) into action rows for Discord messages.
- StringSelectMenuBuilder: Build select menus with custom options for string values.
- StringSelectMenuOptionBuilder: Define options for select menus, including labels, values, descriptions, and emojis.
- UserSelectMenuBuilder: Create menus for selecting users.
- RoleSelectMenuBuilder: Create menus for selecting roles.
- ChannelSelectMenuBuilder: Create menus for selecting channels, with channel type filtering.
Installation
npm install cordix-buildersUsage
Import the builders you need:
const {
EmbedBuilder,
ButtonBuilder,
ActionRowBuilder,
StringSelectMenuBuilder,
StringSelectMenuOptionBuilder,
UserSelectMenuBuilder,
RoleSelectMenuBuilder,
ChannelSelectMenuBuilder,
} = require("cordix-builders");Example: EmbedBuilder
const embed = new EmbedBuilder()
.setAuthor(
"Author",
"https://iili.io/F4VcHnR.png",
"https://iili.io/F4VcHnR.png"
)
.setTitle("Embed Title")
.setURL("https://iili.io/F4VcHnR.png")
.setDescription("Embed description goes here.")
.setColor(0x0099ff)
.setTimestamp()
.setImage("https://iili.io/F4VcHnR.png")
.setThumbnail("https://iili.io/F4VcHnR.png")
.setFooter("Footer text", "https://iili.io/F4VcHnR.png")
.addField("Field Name", "Field Value");
// Send with Cordix:
client.sendMessage(channelId, { embed });Example: ButtonBuilder & ActionRowBuilder
const button = new ButtonBuilder()
.setLabel("Click Me")
.setStyle("primary") // or 1
.setCustomId("my_button");
const row = ActionRowBuilder(button);
client.sendMessage(channelId, {
content: "Here's a button:",
components: [row],
});Example: StringSelectMenuBuilder
const menu = new StringSelectMenuBuilder()
.setCustomId("menu_id")
.setPlaceholder("Choose an option")
.setMaxValues(1)
.setMinValues(1)
.addOption(
new StringSelectMenuOptionBuilder()
.setLabel("Option 1")
.setValue("one")
.setDescription("First option")
.setEmojiId("1234567890")
)
.addOption(
new StringSelectMenuOptionBuilder()
.setLabel("Option 2")
.setValue("two")
.setDescription("Second option")
.setEmojiId("0987654321")
);
const row = ActionRowBuilder(menu);
client.sendMessage(channelId, {
content: "Select an option:",
components: [row],
});Example: UserSelectMenuBuilder
const menu = new UserSelectMenuBuilder()
.setCustomId("user_menu")
.setPlaceholder("Select a user")
.setMaxValues(1)
.setMinValues(1);
const row = ActionRowBuilder(menu);
client.sendMessage(channelId, {
content: "Pick a user:",
components: [row],
});UserSelectMenuBuilder Properties
| Method | Description | | ----------------- | -------------------------------------- | | setCustomId(id) | Set the custom ID for the select menu. | | setPlaceholder(s) | Set the placeholder text. | | setMaxValues(n) | Set the maximum selectable users. | | setMinValues(n) | Set the minimum selectable users. | | setDisabled() | Disable the menu. |
Example: RoleSelectMenuBuilder
const menu = new RoleSelectMenuBuilder()
.setCustomId("role_menu")
.setPlaceholder("Select a role")
.setMaxValues(1)
.setMinValues(1);
const row = ActionRowBuilder(menu);
client.sendMessage(channelId, {
content: "Pick a role:",
components: [row],
});RoleSelectMenuBuilder Properties
| Method | Description | | ----------------- | -------------------------------------- | | setCustomId(id) | Set the custom ID for the select menu. | | setPlaceholder(s) | Set the placeholder text. | | setMaxValues(n) | Set the maximum selectable roles. | | setMinValues(n) | Set the minimum selectable roles. | | setDisabled() | Disable the menu. |
Example: ChannelSelectMenuBuilder
const menu = new ChannelSelectMenuBuilder()
.setCustomId("channel_menu")
.setPlaceholder("Select a channel")
.setMaxValues(1)
.setMinValues(1)
.setChannelTypes([0, 2]); // 0: Text, 2: Voice, etc.
const row = ActionRowBuilder(menu);
client.sendMessage(channelId, {
content: "Pick a channel:",
components: [row],
});ChannelSelectMenuBuilder Properties
| Method | Description | | -------------------- | ---------------------------------------------------- | | setCustomId(id) | Set the custom ID for the select menu. | | setPlaceholder(s) | Set the placeholder text. | | setMaxValues(n) | Set the maximum selectable channels. | | setMinValues(n) | Set the minimum selectable channels. | | setDisabled() | Disable the menu. | | setChannelTypes(arr) | Restrict selectable channel types (array of numbers) |
Additional Info
- All builders use chainable methods for easy configuration.
- You can combine multiple components in a single message.
- Fully compatible with the Cordix library.
License
ISC
Author
ZombieXDev
