mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-17 09:23:07 +02:00
feat: close tickets on channel delete
This commit is contained in:
parent
8e82b2829f
commit
813beb44a0
25
src/listeners/client/channelDelete.js
Normal file
25
src/listeners/client/channelDelete.js
Normal file
@ -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`);
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user