Channel select menus allow users to select one or more Discord channels from the server. They’re useful for channel configuration, announcements, or channel-based features.
Channel select menus dynamically show all channels the user can see. You can filter which channel types users can select using setChannelTypes().
Channel select menus in djs-core are created using the ChannelSelectMenu class. Each select menu component file in src/components/selects/channel/ is automatically registered.
import { ChannelSelectMenu } from "@djs-core/runtime";
export default new ChannelSelectMenu()
.setPlaceholder("Select a channel")
.run(async (interaction) => {
const selectedChannel = interaction.channels.first();
if (selectedChannel) {
await interaction.reply(`You selected: ${selectedChannel.name}`);
}
});
Channel Types
You can filter which channel types users can select:
import { ChannelSelectMenu } from "@djs-core/runtime";
import { ChannelType } from "discord.js";
export default new ChannelSelectMenu()
.setPlaceholder("Select a text channel")
.setChannelTypes([ChannelType.GuildText])
.run(async (interaction) => {
const channel = interaction.channels.first();
if (channel) {
await interaction.reply(`Selected text channel: ${channel.name}`);
}
});
Channel select menus can receive custom data using .setData().
Component Definition
[src/components/selects/channel/config.ts]
import { ChannelSelectMenu } from "@djs-core/runtime";
export default new ChannelSelectMenu<{ category: string }>()
.setPlaceholder("Select channels")
.run(async (interaction, data) => {
const channels = interaction.channels.map((ch) => ch.name);
await interaction.reply(
`Configured ${data.category} channels: ${channels.join(", ")}`,
);
});
configChannelSelect.setData({ category: "announcements" })