minor improvements

This commit is contained in:
Isaac 2023-01-30 17:10:02 +00:00
parent 5579362f26
commit bb3179f28f
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33
4 changed files with 13 additions and 10 deletions

View File

@ -96,6 +96,7 @@ module.exports = class ForceCloseSlashCommand extends SlashCommand {
});
}
// TODO: category
const tickets = await client.prisma.ticket.findMany({
where: {
lastMessageAt: { lte: new Date(Date.now() - time) },

View File

@ -131,10 +131,7 @@ async function logAdminEvent(client, {
async function logTicketEvent(client, {
userId, action, target, diff,
}) {
const ticket = await client.prisma.ticket.findUnique({
include: { guild: true },
where: { id: target.id },
});
const ticket = await client.tickets.getTicket(target.id);
if (!ticket) return;
/** @type {import("discord.js").Guild} */
const guild = client.guilds.cache.get(ticket.guild.id);

View File

@ -17,7 +17,8 @@ module.exports = class extends Listener {
include: { guild: true },
where: { id: channel.id },
});
if (!ticket) return;
if (!ticket?.open) return;
await client.tickets.finallyClose(ticket.id, { reason: 'channel deleted' });
this.client.log.info(`Closed ticket ${ticket.id} because the channel was deleted`);

View File

@ -25,14 +25,18 @@ module.exports = class FeedbackModal extends Modal {
let rating = parseInt(interaction.fields.getTextInputValue('rating')) || null; // any integer, or null if NaN
rating = Math.min(Math.max(rating, 1), 5); // clamp between 1 and 5 (0 and null become 1, 6 becomes 5)
const ticket = await client.prisma.ticket.update({
data: {
feedback: {
create: {
const data = {
comment: comment?.length > 0 ? encrypt(comment) : null,
guild: { connect: { id: interaction.guild.id } },
rating,
user: { connect: { id: interaction.user.id } },
};
const ticket = await client.prisma.ticket.update({
data: {
feedback: {
upsert: {
create: data,
update: data,
},
},
},