I'm trying to script a Ticket System. I sucessfully can create a ticket but i don't know how to close it (delete it) i tried looking up stuff but i couldn't find a solution for my code.
My Code:
case 'ticket':
case 'Ticket':
var guild = client.guilds.cache.get('877207084251369512')
guild.channels.create(message.author.username + '-ticket', {
type: 'text',
topic: 'Ticket' + message.author.id,
parent: '896402801428456046',
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: "877570054710001735",
allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
},
],
})
let created = new Discord.MessageEmbed()
.setTitle("Ticket-System")
.setDescription("You're Ticket was created!")
.setTimestamp()
.setFooter('Ticket System')
.setColor("GREY")
message.channel.send({embeds: [created]});
let channel = message.guild.channels.cache.find(channel => channel.name === `${message.author.username}-ticket`);
message.guild.channels.cache.get(`${channel}`)