To create a select menu, we have three different models:
StringSelectMenuBuilder: This select menu is focused on customization, allowing you to add respective texts and values within its options.
UserSelectMenuBuilder: This select menu is for selecting users; it lists all the users in the server.
ChannelSelectMenuBuilder: This select menu lists the channels in the server. You need to pass the "type" attribute to specify the type of channel you want to fetch. You can find the existing types here.
Practical examples:
StringSelectMenuBuilder
import { ApplicationCommandType } from"discord.js";import { CreateRow, CreateSelect} from"ease-discord-js";exportdefault { name:"test", description:"command to test the library", type:ApplicationCommandType.ChatInput,run:async(client, interaction) => {returninteraction.reply({content:"Hello World!", components: [newCreateRow([CreateSelect.StringSelectMenuBuilder({customId:"test_select", placeholder:"Select a option", options: [ {label:"option one", value:1}, {label:"option two", value:2}, ] }), ]) ]}); }}
Result:
UserSelectMenuBuilder
import { ApplicationCommandType } from"discord.js";import { CreateRow, CreateSelect} from"ease-discord-js";exportdefault { name:"test", description:"command to test the library", type:ApplicationCommandType.ChatInput,run:async(client, interaction) => {returninteraction.reply({content:"Hello World!", components: [newCreateRow([CreateSelect.UserSelectMenuBuilder({customId:"test_select", placeholder:"Select a user"}), ]) ]}); }}
Result:
ChannelSelectMenuBuilder
import { ApplicationCommandType, ChannelType } from"discord.js";import { CreateRow, CreateSelect } from"ease-discord-js";exportdefault { name:"test", description:"command to test the library", type:ApplicationCommandType.ChatInput,run:async(client, interaction) => {returninteraction.reply({content:"Hello World!", components: [newCreateRow([CreateSelect.ChannelSelectMenuBuilder({customId:"test_select", placeholder:"Select a user", type:ChannelType.GuildText}), ]) ]}); }}