From c6c1aacdac116be346d34d101375ccdc10b59f72 Mon Sep 17 00:00:00 2001 From: Isaac Date: Sun, 30 Jul 2023 01:04:42 +0100 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=F0=9F=9A=A8=20being=20able=20to=20c?= =?UTF-8?q?lose=20tickets=20from=20other=20servers=20(closes=20#466)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/slash/force-close.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/slash/force-close.js b/src/commands/slash/force-close.js index 261a34c..977c063 100644 --- a/src/commands/slash/force-close.js +++ b/src/commands/slash/force-close.js @@ -139,6 +139,7 @@ module.exports = class ForceCloseSlashCommand extends SlashCommand { const tickets = await client.prisma.ticket.findMany({ where: { categoryId: categoryId ?? undefined, // must be undefined not null + guildId: interaction.guild.id, lastMessageAt: { lte: new Date(Date.now() - time) }, open: true, }, From 0fe4af0c36372f55fbcb957718e5ff5c5eb855c8 Mon Sep 17 00:00:00 2001 From: Isaac Date: Sun, 30 Jul 2023 01:28:59 +0100 Subject: [PATCH 2/2] fix: keep priority when moving (closes #467) --- src/commands/slash/move.js | 4 ++-- src/commands/slash/priority.js | 36 +++++++++++++--------------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/commands/slash/move.js b/src/commands/slash/move.js index 25c582c..85baa7f 100644 --- a/src/commands/slash/move.js +++ b/src/commands/slash/move.js @@ -2,7 +2,7 @@ const { SlashCommand } = require('@eartharoid/dbf'); const { ApplicationCommandOptionType } = require('discord.js'); const ExtendedEmbedBuilder = require('../../lib/embed'); const { isStaff } = require('../../lib/users'); - +const { getEmoji } = require('./priority'); module.exports = class MoveSlashCommand extends SlashCommand { constructor(client, options) { const name = 'move'; @@ -129,7 +129,7 @@ module.exports = class MoveSlashCommand extends SlashCommand { .replace(/{+\s?num(ber)?\s?}+/gi, ticket.number === 1488 ? '1487b' : ticket.number); await interaction.channel.edit({ lockPermissions: false, - name: channelName, + name: ticket.priority ? getEmoji(ticket.priority) + channelName : channelName, parent: discordCategory, permissionOverwrites: [ { diff --git a/src/commands/slash/priority.js b/src/commands/slash/priority.js index 2a44394..4d1b900 100644 --- a/src/commands/slash/priority.js +++ b/src/commands/slash/priority.js @@ -4,6 +4,15 @@ const ExtendedEmbedBuilder = require('../../lib/embed'); const { logTicketEvent } = require('../../lib/logging'); const { isStaff } = require('../../lib/users'); +const getEmoji = priority => { + const emojis = { + 'HIGH': '🔴', + 'MEDIUM': '🟠', + 'LOW': '🟢', // eslint-disable-line sort-keys + }; + return emojis[priority]; +}; + module.exports = class PrioritySlashCommand extends SlashCommand { constructor(client, options) { const name = 'priority'; @@ -37,25 +46,6 @@ module.exports = class PrioritySlashCommand extends SlashCommand { }); } - getEmoji(priority) { - let emoji; - switch (priority) { - case 'HIGH': { - emoji = '🔴'; - break; - } - case 'MEDIUM': { - emoji = '🟠'; - break; - } - case 'LOW': { - emoji = '🟢'; - break; - } - } - return emoji; - } - /** * * @param {import("discord.js").ChatInputCommandInteraction} interaction @@ -103,8 +93,8 @@ module.exports = class PrioritySlashCommand extends SlashCommand { const priority = interaction.options.getString('priority', true); let name = interaction.channel.name; - if (ticket.priority) name = name.replace(this.getEmoji(ticket.priority), this.getEmoji(priority)); - else name = this.getEmoji(priority) + name; + if (ticket.priority) name = name.replace(getEmoji(ticket.priority), getEmoji(priority)); + else name = getEmoji(priority) + name; await interaction.channel.setName(name); // don't reassign ticket because the original is used below @@ -139,4 +129,6 @@ module.exports = class PrioritySlashCommand extends SlashCommand { }); } -}; \ No newline at end of file +}; + +module.exports.getEmoji = getEmoji;