From 6c443e7c9503f997798d93cd234affc11411c736 Mon Sep 17 00:00:00 2001 From: GramingFoxTeam Date: Thu, 10 Aug 2023 15:27:57 +0300 Subject: [PATCH] fix(bot-discord): fix timeout and undefined var --- apps/bot-discord/src/config.json | 2 +- apps/bot-discord/src/events/ready.js | 2 +- apps/bot-discord/src/utils/muteMember.js | 2 +- apps/bot-discord/src/utils/setMuteTimeout.js | 9 +++++++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/bot-discord/src/config.json b/apps/bot-discord/src/config.json index 6928a33..634666a 100644 --- a/apps/bot-discord/src/config.json +++ b/apps/bot-discord/src/config.json @@ -50,7 +50,7 @@ }, { "name": "🔸 How to ask", - "value": "Include the following information:\n* Version of ReVanced Manager\n*Name of the app you are patching\n*Version of the app you are patching" + "value": "Include the following information:\n* Version of ReVanced Manager\n* Name of the app you are patching\n* Version of the app you are patching" } ], "footer": { diff --git a/apps/bot-discord/src/events/ready.js b/apps/bot-discord/src/events/ready.js index bf86efe..6a018f4 100644 --- a/apps/bot-discord/src/events/ready.js +++ b/apps/bot-discord/src/events/ready.js @@ -10,7 +10,7 @@ export default { const mutes = await client.db.collection('muted').find().toArray(); for (const mute of mutes) { - await setMuteTimeout(mute, client.mutes); + await setMuteTimeout(mute, client.mutes, client); } console.log(`Loaded ${mutes.length} mutes.`); diff --git a/apps/bot-discord/src/utils/muteMember.js b/apps/bot-discord/src/utils/muteMember.js index 8c4f619..a88f902 100644 --- a/apps/bot-discord/src/utils/muteMember.js +++ b/apps/bot-discord/src/utils/muteMember.js @@ -74,7 +74,7 @@ export default async function muteMember(config, member, { duration, reason, sup taken_roles: takenRoles, expires, support_mute: supportMute - }, member.client.mutes); + }, member.client.mutes, member.client); // Return parsed time for the mute command to resolve. return expires; diff --git a/apps/bot-discord/src/utils/setMuteTimeout.js b/apps/bot-discord/src/utils/setMuteTimeout.js index b0f11af..48dc262 100644 --- a/apps/bot-discord/src/utils/setMuteTimeout.js +++ b/apps/bot-discord/src/utils/setMuteTimeout.js @@ -1,5 +1,5 @@ -export default async function setMuteTimeout(mute, mutes) { - const duration = Date.now() - mute.expires; +export default async function setMuteTimeout(mute, mutes, client) { + const duration = (mute.expires - Math.floor(new Date() / 1000)) * 1000; mutes.set(mute.user_id, setTimeout(async() => { const guild = await client.guilds.fetch(mute.guild_id); let member; @@ -15,5 +15,10 @@ export default async function setMuteTimeout(mute, mutes) { config.discord.mute.supportGiveRoles : config.discord.mute.giveRoles ); + + client.db.collection('muted').deleteOne({ + user_id: mute.user_id, + guild_id: mute.guild_id + }); }, duration)); } \ No newline at end of file