0
votes

I'm trying to make discord ticket bot, every thing is okay but I want to the ticket text channel create in the selected category, but with this code the channel will create in none category.
These the part of create channel codes:

function crearTicket(message, user){
    var canal = message.guild.channels.cache.find(c => c.name == `ticket-${user.id}`);
    if (!canal) {
        message.guild.channels.create(`ticket-${user.id}`,{type: "ticket"}).then(channel => { EnviarMensaje(channel, user);

            var rol = message.guild.roles.cache.find(r => r.name === "@everyone");

            channel.createOverwrite(user, {
                SEND_MESSAGES: true,
                VIEW_CHANNEL: true,
                READ_MESSAGE_HISTORY: true,
            });

            channel.createOverwrite(rol, {
                SEND_MESSAGES: false,
                VIEW_CHANNEL: false,
            });

        });

    }
}

And this is the link for all of the code: https://raw.githubusercontent.com/hadiazt/hadiazt.github.io/main/js/bot.js
Thanks for reading my questions

sorry for my bad English

1
"ticket" is not a type option in the CreateChannelDocs. The only types you can create are: ["category","text","voice"] - felony123

1 Answers

0
votes

Assuming you want to make channels underneath a category this how you would make your ticket channels inside a category

message.guild.channels.create('ticket, {
                type: 'category', // CATEGORY
                position: 1, // on top
                permissionOverwrites: [
                    {
                        id: message.guild.id,
                        allow: ['VIEW_CHANNEL'],
                    }]
            }).then(ticket => {
                message.guild.channels.create('ticket-${user.id}', {
                    type: 'text', // TEXT_CHANNEL
                    parent: ticket,
                    permissionOverwrites: [ // affects everyone 
                        {
                            id: message.guild.id,
                            allow: ['VIEW_CHANNEL'],
                            deny: ["CONNECT"],
                        }]
                })