mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 08:13: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({
|
const tickets = await client.prisma.ticket.findMany({
|
||||||
where: {
|
where: {
|
||||||
lastMessageAt: { lte: new Date(Date.now() - time) },
|
lastMessageAt: { lte: new Date(Date.now() - time) },
|
||||||
|
@ -131,10 +131,7 @@ async function logAdminEvent(client, {
|
|||||||
async function logTicketEvent(client, {
|
async function logTicketEvent(client, {
|
||||||
userId, action, target, diff,
|
userId, action, target, diff,
|
||||||
}) {
|
}) {
|
||||||
const ticket = await client.prisma.ticket.findUnique({
|
const ticket = await client.tickets.getTicket(target.id);
|
||||||
include: { guild: true },
|
|
||||||
where: { id: target.id },
|
|
||||||
});
|
|
||||||
if (!ticket) return;
|
if (!ticket) return;
|
||||||
/** @type {import("discord.js").Guild} */
|
/** @type {import("discord.js").Guild} */
|
||||||
const guild = client.guilds.cache.get(ticket.guild.id);
|
const guild = client.guilds.cache.get(ticket.guild.id);
|
||||||
|
@ -17,7 +17,8 @@ module.exports = class extends Listener {
|
|||||||
include: { guild: true },
|
include: { guild: true },
|
||||||
where: { id: channel.id },
|
where: { id: channel.id },
|
||||||
});
|
});
|
||||||
if (!ticket) return;
|
|
||||||
|
if (!ticket?.open) return;
|
||||||
|
|
||||||
await client.tickets.finallyClose(ticket.id, { reason: 'channel deleted' });
|
await client.tickets.finallyClose(ticket.id, { reason: 'channel deleted' });
|
||||||
this.client.log.info(`Closed ticket ${ticket.id} because the channel was 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
|
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)
|
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({
|
const data = {
|
||||||
data: {
|
|
||||||
feedback: {
|
|
||||||
create: {
|
|
||||||
comment: comment?.length > 0 ? encrypt(comment) : null,
|
comment: comment?.length > 0 ? encrypt(comment) : null,
|
||||||
guild: { connect: { id: interaction.guild.id } },
|
guild: { connect: { id: interaction.guild.id } },
|
||||||
rating,
|
rating,
|
||||||
user: { connect: { id: interaction.user.id } },
|
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