From 96ec85f14ab685550cfe06ec8afce47e6adfe6a4 Mon Sep 17 00:00:00 2001 From: Isaac Date: Fri, 30 Sep 2022 21:26:29 +0100 Subject: [PATCH] Add ticket first response --- src/listeners/client/messageCreate.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/listeners/client/messageCreate.js b/src/listeners/client/messageCreate.js index c90db50..bc739ab 100644 --- a/src/listeners/client/messageCreate.js +++ b/src/listeners/client/messageCreate.js @@ -9,7 +9,9 @@ const { SelectMenuBuilder, SelectMenuOptionBuilder, } = require('discord.js'); -const { getCommonGuilds } = require('../../lib/users'); +const { + getCommonGuilds, isStaff, +} = require('../../lib/users'); const ms = require('ms'); const emoji = require('node-emoji'); @@ -192,14 +194,16 @@ module.exports = class extends Listener { } } - if (ticket.firstResponseAt === null) { - ticket = await client.prisma.ticket.update({ - data: { firstResponseAt: new Date() }, - where: { id: ticket.id }, - }); - } + const data = { lastMessageAt: new Date() }; + if ( + ticket.firstResponseAt === null && + await isStaff(message.guild, message.author.id) + ) data.firstResponseAt = new Date(); + ticket = await client.prisma.ticket.update({ + data, + where: { id: ticket.id }, + }); - // TODO: lastMessageAt // TODO: staff status alert, working hours alerts } else { // TODO: auto tag