fix: /move into new category (fixes #531)

This commit is contained in:
Isaac 2025-02-12 02:35:08 +00:00
parent c185afcdfe
commit c1643f45ad
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33

View File

@ -103,15 +103,25 @@ module.exports = class MoveSlashCommand extends SlashCommand {
where: { id: ticket.id }, where: { id: ticket.id },
}); });
const $oldCategory = client.tickets.$count.categories[ticket.categoryId]; // alias
const $newCategory = client.tickets.$count.categories[newCategory.id]; const $counters = client.tickets.$count.categories;
// make sure new category exist (#531)
$counters[newCategory.id] ??= {};
// more specific aliases
const $oldCategory = $counters[ticket.categoryId];
const $newCategory = $counters[newCategory.id];
// decrement old's total and member count
$oldCategory.total--; $oldCategory.total--;
$oldCategory[ticket.createdById]--; $oldCategory[ticket.createdById]--;
// increment new's totaL count
$newCategory.total ||= 0; $newCategory.total ||= 0;
$newCategory.total++; $newCategory.total++;
// increment new's member count
$newCategory[ticket.createdById] ||= 0; $newCategory[ticket.createdById] ||= 0;
$newCategory[ticket.createdById]++; $newCategory[ticket.createdById]++;