'How can i disconnect a user from my voice channel using menu discordjs
So I'm trying to disconnect a specified user that is on my voiceChannel clicking on his username, this is my code:
options = [];
    let perms = channel.members.map(c => c.user.tag)
                   
         for (let i = 0; i < perms.length; i++) {
                         
           options.push({
                    label: `${perms[i]}`,
                    value: `${i}`})     
}
const Select = new MessageSelectMenu()
.setCustomId(`disconnect`)
.setPlaceholder(`Members`)
 .addOptions(options)
.setMaxValues(1);
 const menu = new MessageActionRow()
.addComponents(Select);
const embed = new MessageEmbed()
                .setColor("BLUE" )
                .setDescription("Please select the user from the dropdown to disconnect.");
            interaction.reply({
                embeds: [embed],
                components: [menu], ephemeral: true
            })          
    
    
}
Discord.js v13.
Note: I'm looking for how i can disconnect users from my vc just by selecting their username. Ty.
Solution 1:[1]
I changed up this first part but you can use your way if you'd rather (you'd have to use a different way of getting the member2disconnect). Just seemed easier this way since the value would be the user's id rather than a integer.
const embed = new MessageEmbed()
    .setColor("BLUE")
    .setDescription("Please select the user from the dropdown to disconnect.");
const menu = new MessageActionRow()
    .addComponents(
        new MessageSelectMenu()
        .setCustomId(`disconnect`)
        .setPlaceholder(`Members`)
        .setMaxValues(1),
    );
client.channels.cache.get(interaction.member.voice.channelId).members.forEach(member => {
    menu.components[0].addOptions({
        label: `${member.user.tag}`,
        value: member.user.id,
    });
});
return interaction.reply({
    embeds: [embed],
    components: [menu],
});
This next part goes in your interactionCreate listener
client.on('interactionCreate', async interaction => {
    if (interaction.isSelectMenu()) {
        const selection = interaction.customId;
            if (selection == 'disconnect') {
                const member2disconnect = interaction.guild.members.cache.get(interaction.values[0]);
                member2disconnect.voice.disconnect();
                return interaction.message.edit({
                    content: `${member2disconnect} has been kicked from the VC.`,
                    embeds: [],
                    components: [],
                    ephemeral: true,
                });
            }
    }
});
    					Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | 
