1 回答
TA贡献1864条经验 获得超6个赞
我不确定是什么导致了您的问题,但请尝试在创建频道时设置文本和语音频道的父级:
// GuildChannelManager#create returns the channel you created
message.guild.channels.create(message.author.username, {
type: 'category',
permissionOverwrites: [
{id: message.guild.id, deny: ['VIEW_CHANNEL']},
{id: message.author.id, allow: ['VIEW_CHANNEL']},
]
}).then(parent => {
// Create the text channel
message.guild.channels.create('Text channel', {
type: 'text',
// under the parent category
parent, // shorthand for parent: parent
permissionOverwrites: [
{id: message.guild.id, deny: ['VIEW_CHANNEL']},
{id: message.author.id, allow: ['VIEW_CHANNEL']},
]
}).catch(console.error)
// Same with the voice channel
message.guild.channels.create('Voice channel', {
type: 'voice',
parent,
permissionOverwrites: [
{id: message.guild.id, deny: ['VIEW_CHANNEL']},
{id: message.author.id, allow: ['VIEW_CHANNEL']},
]
}).catch(console.error)
})
你也可以使用 ES2017 的async/await:
// Must be an async function vvvvv
command(client, 'createcategory', async (message) => {
// ...
const parent = await message.guild.channels.create(/* ... */)
try {
// Run the promises concurrently, like in your code
await Promise.all([
message.guild.channels.create('Text channel', {/* ... */})
message.guild.channels.create('Voice channel', {/* ... */)
])
} catch (error) {
console.error(error)
}
// ...
})
添加回答
举报