From 34ab60346217a99faa39b0da171ef6c4b88c223d Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 10 Jul 2024 03:40:22 +0200 Subject: [PATCH] Consider user already opted out when they run /optout to avoid logging them --- events/client/interactionCreate.js | 4 ++++ events/client/messageCreate.js | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/events/client/interactionCreate.js b/events/client/interactionCreate.js index 88a9364..1516c6a 100644 --- a/events/client/interactionCreate.js +++ b/events/client/interactionCreate.js @@ -40,6 +40,10 @@ export default { const isOptOut = await db.optout.findOne({ where: { userID: interaction.user.id } }); + if (commandName === 'optout') { + isOptOut = true + } + const timestamp = new Date(); console.log(`[${timestamp.toISOString()}] \x1b[33m${ isOptOut ? 'A user' : `${userTag} (${userID})`}\x1b[0m launched command \x1b[33m${commandName}\x1b[0m using slash`); diff --git a/events/client/messageCreate.js b/events/client/messageCreate.js index b90bcae..5781c3a 100644 --- a/events/client/messageCreate.js +++ b/events/client/messageCreate.js @@ -302,7 +302,11 @@ export default { const userTag = message.author.username; const userID = message.author.id; - const isOptOut = await db.optout.findOne({ where: { userID: message.author.id } }); + let isOptOut = await db.optout.findOne({ where: { userID: message.author.id } }); + + if (commandName === 'optout') { + isOptOut = true + } const timestamp = new Date(); console.log(`[${timestamp.toISOString()}] \x1b[33m${ isOptOut ? 'A user' : `${userTag} (${userID})`}\x1b[0m launched command \x1b[33m${commandName}\x1b[0m using prefix`);