#ChannelSelectMenu - filter?

1 messages · Page 1 of 1 (latest)

verbal salmon
#

Hi Guys, I'm wondering if there is an easy to use way to filter this. For example filter out channels with less than 10 people in them, don't show channels with the letter G in it or whatever other random logic being applied to it.

On a related note what do you suggest as a solution for including category that the channel is in. (For organising a larger dropdown for example, so its clearer for people to see which channel is which ie. general and general where one is text channel and another is voice).

Here is what I have now:

pearl parrotBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

verbal salmon
#
        try:
            channels_menu = ChannelSelectMenu(
                channel_types=[ChannelType.GUILD_TEXT, ChannelType.GUILD_VOICE, ChannelType.GUILD_NEWS, ChannelType.GUILD_FORUM],
                placeholder="Select channels",
                custom_id="channel_selection",
                min_values=1,
                max_values=25
            )
            await ctx.send("Please select channels from the dropdown menu.", components=[channels_menu], ephemeral=True)
        except Exception as error:
            logger.exception("Error while sending the channel selection menu:")
            await ctx.send(f"Error while sending the channel selection menu: {str(error)}", ephemeral=True)
  
    @component_callback("channel_selection")
    async def select_channels_callback(self, ctx: ComponentContext):
        try:
            selected_channel_ids = ctx.values
            selected_channels = [ctx.guild.get_channel(int(id)) for id in selected_channel_ids]
            selected_channel_names = ', '.join(channel.name for channel in selected_channels if channel)
            # Store the selected channels in a dictionary
            self.selected_channels_dict[ctx.guild_id] = selected_channels
            
            # Send a confirmation button after the user has selected channels
            confirm_button = Button(
                style=ButtonStyle.PRIMARY,
                label="Confirm Selection",
                custom_id="confirm_channels"
            )
            await ctx.send(f"You selected the following channels: {selected_channel_names}", components=[confirm_button], ephemeral=True)```
elder kiln
#

Currently the only thing Discord lets us do is filter by type (the channel_typesparameter)

verbal salmon
#

If you guys have a more elegant solutions please feel free to chime in or reopen 🙂 Thanks again.