mirror of
https://github.com/nx-bat/discordbot-ng.git
synced 2026-11-11 07:13:37 -05:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0124f0ad7a | ||
|
|
6023efe42d |
@@ -1,4 +1,5 @@
|
||||
import { ButtonInteraction, Client, MessageFlags, ChannelType, PermissionFlagsBits } from 'discord.js';
|
||||
import { closeTicket } from '../utils';
|
||||
|
||||
export default {
|
||||
name: 'close-mod-ticket',
|
||||
@@ -19,14 +20,9 @@ export default {
|
||||
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.' });
|
||||
|
||||
channel.edit({
|
||||
name: `[CLOSED] ${channel.name}`.slice(0, 100),
|
||||
archived: true,
|
||||
locked: true
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -5,7 +5,6 @@ export default {
|
||||
name: 'close-ticket',
|
||||
handler: async function (client: Client, interaction: ButtonInteraction) {
|
||||
const channel = await interaction.channel?.fetch();
|
||||
|
||||
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.' });
|
||||
|
||||
@@ -19,8 +18,8 @@ export default {
|
||||
components: []
|
||||
});
|
||||
|
||||
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.' });
|
||||
if (!await closeTicket(client, channel, `This ticket has been closed by ${interaction.user}`))
|
||||
return await interaction.editReply({ content: 'An error occurred while trying to close this ticket.' });
|
||||
|
||||
await interaction.editReply({ content: 'Ticket closed.' });
|
||||
}
|
||||
|
||||
@@ -40,14 +40,14 @@ export async function closeTicket(context: Client, thread: ThreadChannel, reason
|
||||
|
||||
return true;
|
||||
} 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({
|
||||
embeds: [{
|
||||
...SetSeverity('error'),
|
||||
description: 'I encountered an error while trying to close this ticket.',
|
||||
}],
|
||||
});
|
||||
}).catch(() => {});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user