简体   繁体   中英

Discord.js How access to voice channel in voice channels in category?

     var category = client.guilds.get('269811924399685634').channels.get('691715649625653450');
     var voice_channels = category.children.find(c => c.type == 'voice');

I'm set up this. I'm getting voice channels but i can't delete someone of voice channels in this category.

Do you want to delete a channel you get? - Does the bot have permissions?

var voice_channels = category.children.find(c => c.type == 'voice');

- returns first voice channel

If you want to get every channel, use:

var voice_channels = category.children.filter(c => c.type == 'voice');

Deleting a channel: https://discord.js.org/#/docs/main/stable/class/Channel?scrollTo=delete

var voice_channels = category.children.filter(c => c.type == 'voice');
//Discord.js version 12 (I believe)
var channels = voice_channels.map(e => client.channels.resolve(e))
channels[1].delete()
//use client.channels.get(e) in older versions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM