From b4238e26a1551d20aa43b640f56015e606d9502f Mon Sep 17 00:00:00 2001 From: Isaac Date: Wed, 5 Oct 2022 18:26:20 +0100 Subject: [PATCH] fixes --- src/listeners/client/messageCreate.js | 36 ++++++++++++++++----------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/listeners/client/messageCreate.js b/src/listeners/client/messageCreate.js index bc45d18..00aa22a 100644 --- a/src/listeners/client/messageCreate.js +++ b/src/listeners/client/messageCreate.js @@ -194,25 +194,31 @@ module.exports = class extends Listener { } } - await client.prisma.user.update({ - data: { messageCount: { increment: 1 } }, - where: { id: message.author.id }, - }); + if (!message.author.bot) { + await client.prisma.user.upsert({ + create: { + id: message.author.id, + messageCount: 1, + }, + update: { messageCount: { increment: 1 } }, + where: { id: message.author.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 }, - }); + 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: staff status alert, working hours alerts + // TODO: if (!message.author.bot) staff status alert, working hours alerts } - // TODO: auto tag + // TODO: if (!message.author.bot) auto tag } }