mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 00:03:09 +02:00
minor improvements
This commit is contained in:
parent
5579362f26
commit
bb3179f28f
@ -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) },
|
||||
|
@ -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);
|
||||
|
@ -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`);
|
||||
|
@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user