CreateStringSelect
CreateStringSelect creates a string-based select menu component where users pick from a predefined list of text options.
Import
Section titled “Import”import { CreateStringSelect } from "lunibee";import { CreateStringSelect } from "lunibee";Methods
Section titled “Methods”All methods return this for chaining.
setCustomId(id)
Section titled “setCustomId(id)”Sets the custom ID for this select menu (max 100 characters). Required: toJSON() throws without it.
select.setCustomId("color_picker");select.setCustomId("color_picker");setPlaceholder(text)
Section titled “setPlaceholder(text)”Sets the hint text shown when nothing is selected (max 150 characters).
select.setPlaceholder("Choose a color…");select.setPlaceholder("Choose a color…");setMinValues(min)
Section titled “setMinValues(min)”Sets the minimum number of values the user must select (default: 1; an integer from 0 to 25).
select.setMinValues(1);select.setMinValues(1);setMaxValues(max)
Section titled “setMaxValues(max)”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);select.setMaxValues(3);setRequired(required?)
Section titled “setRequired(required?)”Marks the select as required (required defaults to true).
setDisabled(disabled?)
Section titled “setDisabled(disabled?)”Disables the select menu (disabled defaults to true).
select.setDisabled(true);select.setDisabled(true);addOptions(...options)
Section titled “addOptions(...options)”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" },);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" },);toJSON()
Section titled “toJSON()”Serializes to a raw Discord API-compatible component object. Throws when there is no custom ID or no option.
Full Example
Section titled “Full Example”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, });});import { CreateActionRow, CreateStringSelect } from "lunibee";
const row = new CreateActionRow().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, });});