Delete all channels in a specific category

点点圈 提交于 2021-01-28 13:39:58

问题


How to delete all channels in a specific category in Discord.JS? I tried that

oldMember.guild.channels.cache.get(client.tr["Settings"].MainChannelID).parent.channels.cache.forEach(c => {
        if(c.members.size != 0){
            c.delete();
        }
    })

回答1:


You can get all the channels that belong to a category using CategoryChannel.children

const category = await oldMember.guild.channels.cache.get(CATEGORY_ID); // You can use `find` instead of `get` to fetch the category using a name: `find(cat => cat.name === 'test')
category.children.forEach(channel => channel.delete())


来源:https://stackoverflow.com/questions/61826256/delete-all-channels-in-a-specific-category

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!