Skip to content

CreateStringSelect

CreateStringSelect creates a string-based select menu component where users pick from a predefined list of text options.

import { CreateStringSelect } from "lunibee";

All methods return this for chaining.

Sets the custom ID for this select menu (max 100 characters). Required: toJSON() throws without it.

select.setCustomId("color_picker");

Sets the hint text shown when nothing is selected (max 150 characters).

select.setPlaceholder("Choose a color…");

Sets the minimum number of values the user must select (default: 1; an integer from 0 to 25).

select.setMinValues(1);

Sets the maximum number of values the user can select (default: 1, an integer from 1 to 25). toJSON() throws when it exceeds the number of options or is below min_values.

select.setMaxValues(3);

Marks the select as required (required defaults to true).

Disables the select menu (disabled defaults to true).

select.setDisabled(true);

Adds one or more options (max 25 total; calling it with none throws). Each option has:

Field Type Required Description
label string ✅ Visible text (max 100 chars).
value string ✅ Submitted value (max 100 chars).
description string — Subtitle text (max 100 chars).
emoji { id?, name?, animated? } — Emoji to display.
default boolean — Pre-selected state.
select.addOptions(
{ label: "Red", value: "red", emoji: { name: "🔴" }, description: "Bold and passionate" },
{ label: "Blue", value: "blue", emoji: { name: "🔵" }, description: "Calm and collected" },
{ label: "Green", value: "green", emoji: { name: "🟢" }, description: "Fresh and energetic" },
);

Serializes to a raw Discord API-compatible component object. Throws when there is no custom ID or no option.

Role selector

import { CreateActionRow, CreateStringSelect } from "lunibee";
const row = new CreateActionRow<CreateStringSelect>().addComponents(
new CreateStringSelect()
.setCustomId("role_select")
.setPlaceholder("Pick up to 2 roles")
.setMinValues(1)
.setMaxValues(2)
.addOptions(
{ label: "Announcements", value: "announcements", emoji: { name: "📢" } },
{ label: "Updates", value: "updates", emoji: { name: "🔔" } },
{ label: "Gaming", value: "gaming", emoji: { name: "🎮" } },
{ label: "Art", value: "art", emoji: { name: "🎨" } },
),
);
await channel.send({ content: "Subscribe to channels:", components: [row] });
// Handle selection:
client.on("interactionCreate", async (interaction) => {
if (!interaction.isMessageComponent() || interaction.customId !== "role_select") return;
const selected = interaction.values; // e.g. ["announcements", "gaming"]
await interaction.reply({
content: `✅ Subscribed to: ${selected.join(", ")}`,
ephemeral: true,
});
});