fix(bot-discord): fix timeout and undefined var

This commit is contained in:
GramingFoxTeam
2023-08-10 15:27:57 +03:00
parent cb7468a0d4
commit 6c443e7c95
4 changed files with 10 additions and 5 deletions

View File

@@ -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": {

View File

@@ -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.`);

View File

@@ -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;

View File

@@ -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));
}