From 1f24561ac0f22031b5ff27bf3df3961082e31040 Mon Sep 17 00:00:00 2001 From: Isaac Date: Fri, 14 Feb 2025 14:09:51 +0000 Subject: [PATCH] fix: handle missing ticket on`/move` and `/transfer` --- src/commands/slash/move.js | 8 ++++---- src/commands/slash/transfer.js | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/commands/slash/move.js b/src/commands/slash/move.js index 5b5e83b..94b93b7 100644 --- a/src/commands/slash/move.js +++ b/src/commands/slash/move.js @@ -47,15 +47,15 @@ module.exports = class MoveSlashCommand extends SlashCommand { }); if (!ticket) { - const { locale } = await client.prisma.guild.findUnique({ where: { id: interaction.guild.id } }); - const getMessage = client.i18n.getLocale(locale); + const settings = await client.prisma.guild.findUnique({ where: { id: interaction.guild.id } }); + const getMessage = client.i18n.getLocale(settings.locale); return await interaction.editReply({ embeds: [ new ExtendedEmbedBuilder({ iconURL: interaction.guild.iconURL(), - text: ticket.guild.footer, + text: settings.footer, }) - .setColor(ticket.guild.errorColour) + .setColor(settings.errorColour) .setTitle(getMessage('misc.not_ticket.title')) .setDescription(getMessage('misc.not_ticket.description')), ], diff --git a/src/commands/slash/transfer.js b/src/commands/slash/transfer.js index ed22fc2..4283757 100644 --- a/src/commands/slash/transfer.js +++ b/src/commands/slash/transfer.js @@ -3,6 +3,7 @@ const { ApplicationCommandOptionType, EmbedBuilder, } = require('discord.js'); +const ExtendedEmbedBuilder = require('../../lib/embed'); const { quick } = require('../../lib/threads'); @@ -50,6 +51,23 @@ module.exports = class TransferSlashCommand extends SlashCommand { where: { id: interaction.channel.id }, }); + if (!ticket) { + const settings = await client.prisma.guild.findUnique({ where: { id: interaction.guild.id } }); + const getMessage = client.i18n.getLocale(settings.locale); + return await interaction.editReply({ + embeds: [ + new ExtendedEmbedBuilder({ + iconURL: interaction.guild.iconURL(), + text: settings.footer, + }) + .setColor(settings.errorColour) + .setTitle(getMessage('misc.not_ticket.title')) + .setDescription(getMessage('misc.not_ticket.description')), + ], + ephemeral: true, + }); + } + const from = ticket.createdById; const channelName = ticket.category.channelName