discord.js创建类别&;然后在所述类别内创建频道
我正在尝试创建一个设置命令,并为我的bot创建一个专门的类别,例如更新日志和使用的命令。我已经成功地制作了分类,并添加了2个频道,但我似乎无法让它自动将这些频道放入分类中 以下是我目前拥有的代码:discord.js创建类别&;然后在所述类别内创建频道,discord.js,Discord.js,我正在尝试创建一个设置命令,并为我的bot创建一个专门的类别,例如更新日志和使用的命令。我已经成功地制作了分类,并添加了2个频道,但我似乎无法让它自动将这些频道放入分类中 以下是我目前拥有的代码: message.guild.channels.create('Plotting', { type: 'category'} ) message.guild.channels.create(`Log`, { type: 'text'}) message.guild.channe
message.guild.channels.create('Plotting', { type: 'category'} )
message.guild.channels.create(`Log`, { type: 'text'})
message.guild.channels.create('Summary', { type: 'text'})
此代码中没有任何内容说明要在绘图类别中设置的
Log
和Summary
通道。您需要传递parent
选项来设置它。试试这个:
message.guild.channels.create('Plotting', { type: 'category'}).then(CategoryChannel => {
message.guild.channels.create(`Log`, { type: 'text', parent: CategoryChannel});
message.guild.channels.create('Summary', { type: 'text', parent: CategoryChannel});
}).catch();
有关选项的详细信息。可以找到父级
另外,请记住使用.catch()
阻止代码可能不起作用的任何地方。谢谢,这已经起作用了!太好了,请把我的答案记为正确答案:)