Skip to content

Commit

Permalink
v0.15.19
Browse files Browse the repository at this point in the history
- Adding a private message that can be activated and deactivated when a ticket has been closed
  • Loading branch information
LucasB25 committed Jun 5, 2024
1 parent 6721754 commit ab369ea
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "AikouTicket",
"version": "0.15.18",
"version": "0.15.19",
"description": "A simple AikouTicket bot for discord",
"type": "module",
"main": "dist/index.js",
Expand Down
22 changes: 22 additions & 0 deletions src/events/client/InteractionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ export default class InteractionCreate extends Event {
shouldCloseTicket = true;
reason = message.content;
await LogsManager.logTicketDeletion(interaction, this.client, interaction.user.username, categoryLabel, channel, reason);
if (config.notifyTicketCreator) {
await this.notifyTicketCreator(interaction, interaction.user, reason);
}
});

collector.on('end', async () => {
Expand Down Expand Up @@ -305,6 +308,9 @@ export default class InteractionCreate extends Event {
} else {
const reason = 'No reason provided';
await LogsManager.logTicketDeletion(interaction, this.client, interaction.user.username, categoryLabel, channel, reason);
if (config.notifyTicketCreator) {
await this.notifyTicketCreator(interaction, interaction.user, reason);
}

const announcementEmbed = new EmbedBuilder()
.setColor(this.client.color)
Expand All @@ -325,6 +331,22 @@ export default class InteractionCreate extends Event {
}
}

private async notifyTicketCreator(interaction: any, user: any, reason: string | null): Promise<void> {
try {
const reasonText = reason ? `\n\n**Reason:** ${reason}` : '';
const embed = new EmbedBuilder()
.setColor('#FF2400')
.setTitle('Ticket Closed')
.setDescription(`Your ticket has been closed.${reasonText}`)
.setFooter({ text: 'Ticket System', iconURL: interaction.user.displayAvatarURL({ extension: 'png', size: 1024 }) })
.setTimestamp();

await user.send({ embeds: [embed] });
} catch (error) {
this.client.logger.error('Failed to send DM to ticket creator:', error);
}
}

private async handleTranscriptTicketButton(interaction: any): Promise<void> {
const userName = interaction.user.username;
const ticketChannel = interaction.channel;
Expand Down
6 changes: 4 additions & 2 deletions src/utils/LogsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export class LogsManager {
interaction.user.username,
'#2FF200',
'🎟️ Ticket Created',
`- **Ticket Creator:** \n> ${interaction.user.username}\n\n- **Ticket:** \n> ${ticketChannel.toString()} \n> (${ticketChannel.name
`- **Ticket Creator:** \n> ${interaction.user.username}\n\n- **Ticket:** \n> ${ticketChannel.toString()} \n> (${
ticketChannel.name
} - ID: ${ticketChannel.id}) \n\n- **Category:** \n> ${categoryLabel}`,
);
await logChannel.send({ embeds: [embed] });
Expand Down Expand Up @@ -82,7 +83,8 @@ export class LogsManager {
userName,
'#3498DB',
'📝 Transcript Generated',
`- **Transcript Generated By:** \n> ${interaction.user.username}\n\n- **Ticket:** \n> ${ticketChannel.toString()} \n> (${ticketChannel.name
`- **Transcript Generated By:** \n> ${interaction.user.username}\n\n- **Ticket:** \n> ${ticketChannel.toString()} \n> (${
ticketChannel.name
} - ID: ${ticketChannel.id})`,
);

Expand Down
1 change: 1 addition & 0 deletions src/utils/TicketManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface Config {
enableClaimButton: boolean;
closeTicketStaffOnly: boolean;
enableTicketReason: boolean;
notifyTicketCreator: boolean;
ticketCategories: {
[key: string]: {
menuLabel: string;
Expand Down

0 comments on commit ab369ea

Please sign in to comment.