我想做一个机器人,设计了一个服务器,所以它的工作是使渠道和角色,所以所有者不必浪费时间设置服务器。 这是我的代码:
if (message.content === 'tchannel') {
message.guild.channels.create('Important', {
type: 'category',
permissionOverwrites: [
{
id: message.guild.id,
allow: ['VIEW_CHANNEL'],
}]
})
message.guild.channels.create('Rules', {
type: 'text',
permissionOverwrites: [
{
id: message.guild.id,
allow: ['VIEW_CHANNEL'],
}]
})
message.channel.send("Channel Created!")
}
我想知道的是,如果有一种方法,使文本通道连接到类别,而不是单独的?
(https://media.discordapp.net/attachments/730705963018879007/730771756784156752/lol.png)
只需添加。then方法并从中获取parentID。 或者,您可以将类别分配给一个变量,如果您将使用它,则在之后分配它。
message.guild.channels.create('Important', {
type: 'category',
permissionOverwrites: [
{
id: message.guild.id,
allow: ['VIEW_CHANNEL'],
}]
}).then(cat => {
message.guild.channels.create('Rules', {
type: 'text',
parent: cat.parentID,
permissionOverwrites: [
{
id: message.guild.id,
allow: ['VIEW_CHANNEL'],
}]
})
})