(tickets): Move ticket closure functionality to a seperate utilities function & replace close-ticket logic with .

This commit is contained in:
2026-10-13 22:50:31 +08:00
parent 5173b3fd2a
commit 8115c27d56
2 changed files with 52 additions and 27 deletions
+10 -12
View File
@@ -1,5 +1,5 @@
import { ButtonInteraction, Client, MessageFlags, ChannelType } from 'discord.js';
import { Database } from '../shared/Database';
import { closeTicket } from '../utils';
export default {
name: 'close-ticket',
@@ -7,23 +7,21 @@ export default {
const channel = await interaction.channel?.fetch();
if (!channel || !channel.isThread() || !channel.isSendable() || channel.type != ChannelType.PrivateThread)
return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Oops. Something went wrong. Please report this to a staff member.' });
return await interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Oops. Something went wrong. Please report this to a staff member.' });
await interaction.reply({
content: 'Closing, please wait...',
flags: MessageFlags.Ephemeral
});
await interaction.message.edit({
content: interaction.message.content,
components: []
});
await Database.closePrivateHelpTicket(channel.id);
if (await closeTicket(client, channel, `This ticket has been closed by ${interaction.user}`))
return await interaction.editReply({ content: 'An error occured while trying to close this ticket.' });
await channel.send(`This ticket has been closed by ${interaction.user}`);
await interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Ticket closed.' });
channel.edit({
name: `[CLOSED] ${channel.name}`.slice(0, 100),
archived: true,
locked: true
});
await interaction.editReply({ content: 'Ticket closed.' });
}
};