0

I'm trying to script a Ticket System. I can create my channel but unfortunately not delete it with a command. My Bot has all the permissions that are needed.

My Ticket System:

case 'ticket':
        case 'Ticket':

            var guild = client.guilds.cache.get('877207087521369512')
            guild.channels.create(message.author.username + '-ticket', {
                type: 'text',
                topic:  message.author.id + '-ticket',
                parent: '896402801254446046',
                permissionOverwrites: [
                    {
                     id: message.author.id,
                     allow: ['SEND_MESSAGES', 'VIEW_CHANNEL', 'READ_MESSAGE_HISTORY', 'EMBED_LINKS', 'ATTACH_FILES'],
                    },
                    {
                     id: message.guild.roles.everyone,
                     deny: ['VIEW_CHANNEL'],
                    },
                {
                     id: "8775700854001735",
                     allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
                    },
                   ],
                  })

            let created = new Discord.MessageEmbed()
            .setTitle("Ticket-System")
            .setDescription("You're ticket is created")
            .setTimestamp()
            .setColor("GREY")
            
            
            message.channel.send({embeds: [created]});
            
            let newchannel = message.guild.channels.cache.find(channel => channel.name === `${message.author.username}-ticket`);
            message.guild.channels.cache.get(`${newchannel}`) 

My code for deleting a channel:

if (message.content.startsWith(prefix + 'close')) {
  message.channel.delete()
}
MrMythical
  • 8,908
  • 2
  • 17
  • 45
I need Help
  • 204
  • 3
  • 13

0 Answers0