mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-22 15:53:08 +02:00
fix: update counters when transferring (closes #468)
This commit is contained in:
parent
77e5b45aa8
commit
d1e30ce069
@ -49,29 +49,46 @@ module.exports = class TransferSlashCommand extends SlashCommand {
|
|||||||
},
|
},
|
||||||
where: { id: interaction.channel.id },
|
where: { id: interaction.channel.id },
|
||||||
});
|
});
|
||||||
const from = ticket.createdById;
|
|
||||||
|
|
||||||
await client.prisma.ticket.update({
|
const from = ticket.createdById;
|
||||||
data: {
|
|
||||||
createdBy: {
|
|
||||||
connectOrCreate: {
|
|
||||||
create: { id: member.id },
|
|
||||||
where: { id: member.id },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
where: { id: interaction.channel.id },
|
|
||||||
});
|
|
||||||
|
|
||||||
const channelName = ticket.category.channelName
|
const channelName = ticket.category.channelName
|
||||||
.replace(/{+\s?(user)?name\s?}+/gi, member.user.username)
|
.replace(/{+\s?(user)?name\s?}+/gi, member.user.username)
|
||||||
.replace(/{+\s?(nick|display)(name)?\s?}+/gi, member.displayName)
|
.replace(/{+\s?(nick|display)(name)?\s?}+/gi, member.displayName)
|
||||||
.replace(/{+\s?num(ber)?\s?}+/gi, ticket.number === 1488 ? '1487b' : ticket.number);
|
.replace(/{+\s?num(ber)?\s?}+/gi, ticket.number === 1488 ? '1487b' : ticket.number);
|
||||||
|
|
||||||
await interaction.channel.edit({
|
await Promise.all([
|
||||||
name: channelName,
|
client.prisma.ticket.update({
|
||||||
topic: `${member.toString()}${ticket.topic?.length > 0 ? ` | ${decrypt(ticket.topic)}` : ''}`,
|
data: {
|
||||||
});
|
createdBy: {
|
||||||
|
connectOrCreate: {
|
||||||
|
create: { id: member.id },
|
||||||
|
where: { id: member.id },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
where: { id: interaction.channel.id },
|
||||||
|
}),
|
||||||
|
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({
|
await interaction.editReply({
|
||||||
embeds: [
|
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,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user