2 Commits
3 changed files with 7 additions and 12 deletions
+3 -7
View File
@@ -1,4 +1,5 @@
import { ButtonInteraction, Client, MessageFlags, ChannelType, PermissionFlagsBits } from 'discord.js'; import { ButtonInteraction, Client, MessageFlags, ChannelType, PermissionFlagsBits } from 'discord.js';
import { closeTicket } from '../utils';
export default { export default {
name: 'close-mod-ticket', name: 'close-mod-ticket',
@@ -19,14 +20,9 @@ export default {
components: [] components: []
}); });
await channel.send('This ticket has been closed by staff.'); if (!await closeTicket(client, channel, `This ticket has been closed by staff.`))
return await interaction.editReply({ content: 'An error occurred while trying to close this ticket.' });
await interaction.editReply({ content: 'Ticket closed.' }); await interaction.editReply({ content: 'Ticket closed.' });
channel.edit({
name: `[CLOSED] ${channel.name}`.slice(0, 100),
archived: true,
locked: true
});
} }
}; };
+2 -3
View File
@@ -5,7 +5,6 @@ export default {
name: 'close-ticket', name: 'close-ticket',
handler: async function (client: Client, interaction: ButtonInteraction) { handler: async function (client: Client, interaction: ButtonInteraction) {
const channel = await interaction.channel?.fetch(); const channel = await interaction.channel?.fetch();
if (!channel || !channel.isThread() || !channel.isSendable() || channel.type != ChannelType.PrivateThread) if (!channel || !channel.isThread() || !channel.isSendable() || channel.type != ChannelType.PrivateThread)
return await 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.' });
@@ -19,8 +18,8 @@ export default {
components: [] components: []
}); });
if (await closeTicket(client, channel, `This ticket has been closed by ${interaction.user}`)) 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.' }); return await interaction.editReply({ content: 'An error occurred while trying to close this ticket.' });
await interaction.editReply({ content: 'Ticket closed.' }); await interaction.editReply({ content: 'Ticket closed.' });
} }
+2 -2
View File
@@ -40,14 +40,14 @@ export async function closeTicket(context: Client, thread: ThreadChannel, reason
return true; return true;
} catch (error) { } catch (error) {
console.log('An error occured while trying to close the ticket:', error); console.error('An error occured while trying to close the ticket:', error);
await thread.send({ await thread.send({
embeds: [{ embeds: [{
...SetSeverity('error'), ...SetSeverity('error'),
description: 'I encountered an error while trying to close this ticket.', description: 'I encountered an error while trying to close this ticket.',
}], }],
}); }).catch(() => {});
return false; return false;
} }