Skip to content

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 { CreateActionRow } from "lunibee";

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>();

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),
);

Removes every component from the row.

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.

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] });

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] });

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);

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.