StringSelectBuilder
StringSelectBuilder creates a string-based select menu component where users pick from a predefined list of text options.
Import
Section titled “Import”import { StringSelectBuilder } from "lunibee";import { StringSelectBuilder } 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.
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).
select.setMinValues(1);select.setMinValues(1);setMaxValues(max)
Section titled “setMaxValues(max)”Sets the maximum number of values the user can select (default: 1, max: 25).
select.setMaxValues(3);select.setMaxValues(3);setDisabled(disabled?)
Section titled “setDisabled(disabled?)”Disables the select menu.
select.setDisabled(true);select.setDisabled(true);addOptions(...options)
Section titled “addOptions(...options)”Adds one or more options (max 25 total). 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 |
string | object |
— | Emoji to display. |
default |
boolean |
— | Pre-selected state. |
select.addOptions( { label: "Red", value: "red", emoji: "🔴", description: "Bold and passionate" }, { label: "Blue", value: "blue", emoji: "🔵", description: "Calm and collected" }, { label: "Green", value: "green", emoji: "🟢", description: "Fresh and energetic" },);select.addOptions( { label: "Red", value: "red", emoji: "🔴", description: "Bold and passionate" }, { label: "Blue", value: "blue", emoji: "🔵", description: "Calm and collected" }, { label: "Green", value: "green", emoji: "🟢", description: "Fresh and energetic" },);setOptions(...options)
Section titled “setOptions(...options)”Replaces all options with a new set.
toJSON()
Section titled “toJSON()”Serializes to a raw Discord API-compatible component object.
Full Example
Section titled “Full Example”Role selector
import { ActionRowBuilder, StringSelectBuilder } from "lunibee";
const row = new ActionRowBuilder<StringSelectBuilder>().addComponents( new StringSelectBuilder() .setCustomId("role_select") .setPlaceholder("Pick up to 2 roles") .setMinValues(1) .setMaxValues(2) .addOptions( { label: "Announcements", value: "announcements", emoji: "📢" }, { label: "Updates", value: "updates", emoji: "🔔" }, { label: "Gaming", value: "gaming", emoji: "🎮" }, { label: "Art", value: "art", emoji: "🎨" }, ),);
await channel.send({ content: "Subscribe to channels:", components: [row] });
// Handle selection:client.on("interactionCreate", async (interaction) => { if (!interaction.isComponent() || interaction.customId !== "role_select") return; const selected = interaction.values; // e.g. ["announcements", "gaming"] await interaction.reply({ content: `✅ Subscribed to: ${selected.join(", ")}`, ephemeral: true, });});import { ActionRowBuilder, StringSelectBuilder } from "lunibee";
const row = new ActionRowBuilder().addComponents( new StringSelectBuilder() .setCustomId("role_select") .setPlaceholder("Pick up to 2 roles") .setMinValues(1) .setMaxValues(2) .addOptions( { label: "Announcements", value: "announcements", emoji: "📢" }, { label: "Updates", value: "updates", emoji: "🔔" }, { label: "Gaming", value: "gaming", emoji: "🎮" }, { label: "Art", value: "art", emoji: "🎨" }, ),);
await channel.send({ content: "Subscribe to channels:", components: [row] });
// Handle selection:client.on("interactionCreate", async (interaction) => { if (!interaction.isComponent() || interaction.customId !== "role_select") return; const selected = interaction.values; // e.g. ["announcements", "gaming"] await interaction.reply({ content: `✅ Subscribed to: ${selected.join(", ")}`, ephemeral , });});