diff --git a/src/listeners/client/channelDelete.js b/src/listeners/client/channelDelete.js new file mode 100644 index 0000000..58e5dc3 --- /dev/null +++ b/src/listeners/client/channelDelete.js @@ -0,0 +1,25 @@ +const { Listener } = require('@eartharoid/dbf'); + +module.exports = class extends Listener { + constructor(client, options) { + super(client, { + ...options, + emitter: client, + event: 'channelDelete', + }); + } + + async run(channel) { + /** @type {import("client")} */ + const client = this.client; + + const ticket = await client.prisma.ticket.findUnique({ + include: { guild: true }, + where: { id: channel.id }, + }); + if (!ticket) return; + + await client.tickets.close(ticket.id, true, 'channel deleted'); + this.client.log.info(`Closed ticket ${ticket.id} because the channel was deleted`); + } +};