Discord.js如何在类别的语音通道中访问语音通道?

时间:2020-03-24 16:02:23

标签: javascript node.js bots discord discord.js

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

我已经设置好了。我正在获取语音通道,但无法删除此类别的某个语音通道。

1 个答案:

答案 0 :(得分:0)

您要删除获得的频道吗? -该机器人具有权限吗?

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

-返回第一个语音通道

如果要获取每个频道,请使用:

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

删除频道: 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