feat: DM on close (fixes #338)

A very basic message to notify the user of the ticket closure
This commit is contained in:
Isaac 2023-01-30 16:58:36 +00:00
parent d1c3620fcd
commit 5579362f26
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33
2 changed files with 32 additions and 1 deletions

View File

@ -230,6 +230,9 @@ commands:
create:
name: Create a ticket for user
dm:
closed:
archived: Type `/transcript` in **{guild}** to view the archived messages.
title: Your ticket has been closed
confirm_open:
title: Do you want to open a ticket with the following topic?
log:

View File

@ -1081,10 +1081,38 @@ module.exports = class TicketManager {
where: { id: ticket.id },
});
if (channel?.deletable) {
const member = closedBy ? channel.guild.members.cache.get(closedBy) : null;
await channel.delete('Ticket closed' + (member ? ` by ${member.displayName}` : '') + reason ? `: ${reason}` : '');
}
if (closedBy) {
logTicketEvent(this.client, {
action: 'close',
target: {
id: ticket.id,
name: channel.toString(),
},
userId: closedBy,
});
}
try {
const creator = await channel?.guild.members.fetch(ticket.createdById);
if (creator) {
const getMessage = this.client.i18n.getLocale(ticket.guild.locale);
const embed = new ExtendedEmbedBuilder({
iconURL: channel.guild.iconURL(),
text: ticket.guild.footer,
})
.setColor(ticket.guild.primaryColour)
.setTitle(getMessage('dm.closed.title'));
if (ticket.guild.archive) embed.setDescription(getMessage('dm.closed.archived', { guild: channel.guild.name }));
await creator.send({ embeds: [embed] });
}
} catch (error) {
this.client.log.error(error);
}
}
};