fix: update counters when transferring (closes #468)

This commit is contained in:
Isaac 2023-08-25 01:22:11 +01:00
parent 77e5b45aa8
commit d1e30ce069
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33

View File

@ -49,9 +49,16 @@ module.exports = class TransferSlashCommand extends SlashCommand {
},
where: { id: interaction.channel.id },
});
const from = ticket.createdById;
await client.prisma.ticket.update({
const channelName = ticket.category.channelName
.replace(/{+\s?(user)?name\s?}+/gi, member.user.username)
.replace(/{+\s?(nick|display)(name)?\s?}+/gi, member.displayName)
.replace(/{+\s?num(ber)?\s?}+/gi, ticket.number === 1488 ? '1487b' : ticket.number);
await Promise.all([
client.prisma.ticket.update({
data: {
createdBy: {
connectOrCreate: {
@ -61,17 +68,27 @@ module.exports = class TransferSlashCommand extends SlashCommand {
},
},
where: { id: interaction.channel.id },
});
const channelName = ticket.category.channelName
.replace(/{+\s?(user)?name\s?}+/gi, member.user.username)
.replace(/{+\s?(nick|display)(name)?\s?}+/gi, member.displayName)
.replace(/{+\s?num(ber)?\s?}+/gi, ticket.number === 1488 ? '1487b' : ticket.number);
await interaction.channel.edit({
}),
interaction.channel.edit({
name: channelName,
topic: `${member.toString()}${ticket.topic?.length > 0 ? ` | ${decrypt(ticket.topic)}` : ''}`,
});
}),
interaction.channel.permissionOverwrites.edit(
member,
{
AttachFiles: true,
EmbedLinks: true,
ReadMessageHistory: true,
SendMessages: true,
ViewChannel: true,
},
),
]);
const $category = client.tickets.$count.categories[ticket.categoryId];
$category[from]--;
$category[member.id] ||= 0;
$category[member.id]++;
await interaction.editReply({
embeds: [
@ -86,15 +103,5 @@ module.exports = class TransferSlashCommand extends SlashCommand {
],
});
await interaction.channel.permissionOverwrites.edit(
member,
{
AttachFiles: true,
EmbedLinks: true,
ReadMessageHistory: true,
SendMessages: true,
ViewChannel: true,
},
);
}
};