From 0dafa532af55c83d0ef04d0b09db41788a52f06d Mon Sep 17 00:00:00 2001 From: Tas33n <55633040+tas33n@users.noreply.github.com> Date: Sun, 14 Jan 2024 11:45:03 +0600 Subject: [PATCH] turn of busy when user active in chat busy/Afk should turned off when the afk user sends message. --- scripts/cmds/busy.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/cmds/busy.js b/scripts/cmds/busy.js index a568766d47..febc6074a7 100644 --- a/scripts/cmds/busy.js +++ b/scripts/cmds/busy.js @@ -4,6 +4,7 @@ if (!global.client.busyList) module.exports = { config: { name: "busy", + aliases: ["afk"], version: "1.5", author: "NTKhang", countDown: 5, @@ -63,8 +64,16 @@ module.exports = { ); }, - onChat: async ({ event, message, getLang }) => { - const { mentions } = event; + onChat: async ({ event, message, usersData, getLang }) => { + const { mentions, senderID } = event; + + const isAfk = global.db.allUserData.find(item => item.userID == senderID)?.data.busy || false; + if (isAfk) { + const { data } = await usersData.get(senderID); + delete data.busy; + await usersData.set(senderID, data, "data"); + return message.reply(getLang("turnedOff")); + } if (!mentions || Object.keys(mentions).length == 0) return; @@ -80,4 +89,4 @@ module.exports = { } } } -}; \ No newline at end of file +};