CreateActionRow
CreateActionRow is a generic container that holds interactive components (buttons, select menus, or text inputs in modals). Each message can have up to 5 action rows.
Import
Section titled “Import”import { CreateActionRow } from "lunibee";import { CreateActionRow } from "lunibee";Generic Type Parameter
Section titled “Generic Type Parameter”CreateActionRow<T> is typed to the component it will hold. This provides type-safe addComponents() calls:
import { CreateActionRow, CreateButton, CreateStringSelect } from "lunibee";
const buttonRow = new CreateActionRow<CreateButton>();const selectRow = new CreateActionRow<CreateStringSelect>();import { CreateActionRow, CreateButton, CreateStringSelect } from "lunibee";
const buttonRow = new CreateActionRow();const selectRow = new CreateActionRow();Methods
Section titled “Methods”addComponents(...components)
Section titled “addComponents(...components)”Adds one or more components to the row (max 5 buttons or 1 select menu per row). Throws a TypeError when called with no components and a RangeError when the row would hold more than 5.
const row = new CreateActionRow<CreateButton>().addComponents( new CreateButton().setCustomId("a").setLabel("A").setStyle(1), new CreateButton().setCustomId("b").setLabel("B").setStyle(2),);const row = new CreateActionRow().addComponents( new CreateButton().setCustomId("a").setLabel("A").setStyle(1), new CreateButton().setCustomId("b").setLabel("B").setStyle(2),);clearComponents()
Section titled “clearComponents()”Removes every component from the row.
toJSON()
Section titled “toJSON()”Serializes to a raw Discord API-compatible action row object. Throws a RangeError when the row is empty, or when a select menu or text input shares the row with another component.
Examples
Section titled “Examples”Three-button row
import { CreateActionRow, CreateButton, ButtonType } from "lunibee";
const row = new CreateActionRow<CreateButton>().addComponents( new CreateButton().setCustomId("prev").setLabel("◀ Previous").setStyle(ButtonType.Secondary), new CreateButton().setCustomId("stop").setLabel("⏹ Stop").setStyle(ButtonType.Danger), new CreateButton().setCustomId("next").setLabel("Next ▶").setStyle(ButtonType.Secondary),);await channel.send({ content: "Page 1 of 5", components: [row] });import { CreateActionRow, CreateButton, ButtonType } from "lunibee";
const row = new CreateActionRow().addComponents( new CreateButton().setCustomId("prev").setLabel("◀ Previous").setStyle(ButtonType.Secondary), new CreateButton().setCustomId("stop").setLabel("⏹ Stop").setStyle(ButtonType.Danger), new CreateButton().setCustomId("next").setLabel("Next ▶").setStyle(ButtonType.Secondary),);await channel.send({ content: "Page 1 of 5", components: [row] });Select menu row
import { CreateActionRow, CreateStringSelect } from "lunibee";
const row = new CreateActionRow<CreateStringSelect>().addComponents( new CreateStringSelect() .setCustomId("pick_role") .setPlaceholder("Pick a role…") .addOptions( { label: "Developer", value: "dev", emoji: { name: "💻" } }, { label: "Designer", value: "design", emoji: { name: "🎨" } }, ),);await channel.send({ content: "Choose your role:", components: [row] });import { CreateActionRow, CreateStringSelect } from "lunibee";
const row = new CreateActionRow().addComponents( new CreateStringSelect() .setCustomId("pick_role") .setPlaceholder("Pick a role…") .addOptions( { label: "Developer", value: "dev", emoji: { name: "💻" } }, { label: "Designer", value: "design", emoji: { name: "🎨" } }, ),);await channel.send({ content: "Choose your role:", components: [row] });Modal with text input (using CreateActionRow)
import { CreateActionRow, CreateTextInput, TextInputType, CreateModal } from "lunibee";
const modal = new CreateModal() .setCustomId("feedback") .setTitle("Send Feedback") .addComponents( new CreateActionRow<CreateTextInput>().addComponents( new CreateTextInput() .setCustomId("message") .setLabel("Your feedback") .setStyle(TextInputType.Paragraph), ), );await interaction.showModal(modal);import { CreateActionRow, CreateTextInput, TextInputType, CreateModal } from "lunibee";
const modal = new CreateModal() .setCustomId("feedback") .setTitle("Send Feedback") .addComponents( new CreateActionRow().addComponents( new CreateTextInput() .setCustomId("message") .setLabel("Your feedback") .setStyle(TextInputType.Paragraph), ), );await interaction.showModal(modal);Payload types
Section titled “Payload types”The shapes toJSON() returns are exported from lunibee, so helpers that build or accept raw
component payloads need no ReturnType<...> tricks:
import type { APIComponent, APIActionRowChild, APIActionRowPayload, APIButtonPayload, APITextInputPayload, APIStringSelectComponent, APIEntitySelectComponent, APISelectOption, APIContainerComponent, APITextDisplayComponent, APIModalComponent,} from "lunibee";
const rows: APIActionRowPayload[] = [new CreateActionRow().addComponents(button).toJSON()];APIActionRowComponent, APIButtonComponent and APITextInputComponent keep naming the shapes
Discord sends (for example on message.components); the builder output for those three is
exported as APIActionRowPayload, APIButtonPayload and APITextInputPayload.