Skip to content Skip to sidebar Skip to footer

!createcategory | Doesn't Create Category | What To Do? Discord.js

client.on('ready', () => { command(client, 'createcategory', (message) => { const name = message.content.replace('!createcategory ', '') if(message.gui

Solution 1:

I'm not sure what's causing your issue, but try setting the parent of the text and voice channels when you create the channel:

// 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: parentpermissionOverwrites: [
            {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)
})

You could also use ES2017's async/await:

// Must be an async function      vvvvvcommand(client, 'createcategory', async (message) => {
   // ...const parent = await message.guild.channels.create(/* ... */)
    try {
        // Run the promises concurrently, like in your codeawaitPromise.all([
            message.guild.channels.create('Text channel', {/* ... */})
            message.guild.channels.create('Voice channel', {/* ... */)
        ])
    } catch (error) {
        console.error(error)
    }
    // ...
})

Post a Comment for "!createcategory | Doesn't Create Category | What To Do? Discord.js"