User, Role, Mentionable and Channel Select
type: 5 · 6 · 7 · 8
Messages
Modals
Preview payload.json
Role Select with a pre-selected role
These menus don’t need options: Discord fills the list automatically with the server’s data.
| Type | Name | Shows |
|---|---|---|
5 |
User Select | Users |
6 |
Role Select | Roles |
7 |
Mentionable Select | Users and roles |
8 |
Channel Select | Channels (filterable by type) |
{ "flags": 32768, "components": [ { "type": 17, "components": [ { "type": 10, "content": "### ⚙️ Server settings" }, { "type": 10, "content": "**Welcome channel**" }, { "type": 1, "components": [ { "type": 8, "custom_id": "welcome_channel", "placeholder": "Pick a text channel", "channel_types": [ 0 ] } ] }, { "type": 10, "content": "**Moderator roles**" }, { "type": 1, "components": [ { "type": 6, "custom_id": "mod_roles", "placeholder": "Pick roles", "max_values": 5 } ] }, { "type": 10, "content": "**VIP users**" }, { "type": 1, "components": [ { "type": 5, "custom_id": "vips", "max_values": 10 } ] } ] } ]}Fields
Section titled “Fields”| Field | Type | Description |
|---|---|---|
type |
integer | required 5, 6, 7 or 8. |
id |
integer | optional Unique identifier. |
custom_id |
string | required 1-100 characters. |
placeholder |
string | optional Max 150 characters. |
default_values |
array of default values | optional Pre-selected items. Their count must be between min_values and max_values. |
min_values |
integer | optional 0-25. Defaults to 1. |
max_values |
integer | optional Max 25. Defaults to 1. |
channel_types |
array of integers | optional Channel Select only. Allowed channel types. |
required |
boolean | optional Modals only. Defaults to true. |
disabled |
boolean | optional Messages only. Defaults to false. |
Default values
Section titled “Default values”| Field | Type | Description |
|---|---|---|
id |
snowflake | User, role or channel ID. |
type |
string | "user", "role" or "channel". |
{ "type": 6, "custom_id": "notification_role", "default_values": [{ "id": "123456789012345678", "type": "role" }]}Common channel types
Section titled “Common channel types”| Value | Type |
|---|---|
0 |
Text channel |
2 |
Voice channel |
4 |
Category |
5 |
Announcement channel |
13 |
Stage |
15 |
Forum |
What your bot receives
Section titled “What your bot receives”data.values contains the selected IDs, and data.resolved contains the full data:
{ "custom_id": "mod_roles", "component_type": 6, "values": ["123456789012345678"], "resolved": { "roles": { "123456789012345678": { "id": "123456789012345678", "name": "Moderator", "color": 5793266 } } }}Use the JSON above as the message body.
import { ActionRowBuilder, ChannelSelectMenuBuilder, RoleSelectMenuBuilder, UserSelectMenuBuilder, ChannelType,} from 'discord.js';
const channelRow = new ActionRowBuilder().addComponents( new ChannelSelectMenuBuilder() .setCustomId('welcome_channel') .setPlaceholder('Pick a text channel') .setChannelTypes(ChannelType.GuildText),);
const roleRow = new ActionRowBuilder().addComponents( new RoleSelectMenuBuilder().setCustomId('mod_roles').setPlaceholder('Pick roles').setMaxValues(5),);
const userRow = new ActionRowBuilder().addComponents( new UserSelectMenuBuilder().setCustomId('vips').setMaxValues(10),);
// Reading the selectionclient.on('interactionCreate', async (interaction) => { if (interaction.isRoleSelectMenu() && interaction.customId === 'mod_roles') { const roles = interaction.roles; // Collection of selected roles }});channel_select = discord.ui.ChannelSelect( custom_id="welcome_channel", placeholder="Pick a text channel", channel_types=[discord.ChannelType.text],)role_select = discord.ui.RoleSelect(custom_id="mod_roles", placeholder="Pick roles", max_values=5)user_select = discord.ui.UserSelect(custom_id="vips", max_values=10)
async def on_roles(interaction: discord.Interaction): names = ", ".join(role.name for role in role_select.values) await interaction.response.send_message(f"Roles: {names}", ephemeral=True)
role_select.callback = on_rolesmaxRoles := 5channelRow := discordgo.ActionsRow{Components: []discordgo.MessageComponent{ discordgo.SelectMenu{ MenuType: discordgo.ChannelSelectMenu, CustomID: "welcome_channel", Placeholder: "Pick a text channel", ChannelTypes: []discordgo.ChannelType{discordgo.ChannelTypeGuildText}, },}}
roleRow := discordgo.ActionsRow{Components: []discordgo.MessageComponent{ discordgo.SelectMenu{ MenuType: discordgo.RoleSelectMenu, CustomID: "mod_roles", Placeholder: "Pick roles", MaxValues: maxRoles, DefaultValues: []discordgo.SelectMenuDefaultValue{ {ID: "123456789012345678", Type: discordgo.SelectMenuDefaultValueRole}, }, },}}