forked from servorelif/bos-dosya
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unmutes.js
33 lines (30 loc) · 986 Bytes
/
unmutes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const data = require("../models/chatmute.js")
let serverSettings = require("../models/serverSettings");
module.exports = client => {
setInterval(async () => {
let muted = await data.find({
"muted": true,
"endDate": {
$lte: Date.now()
}
})
muted.forEach(async memberdata => {
let server = await serverSettings.findOne({
});
let sunucu = client.guilds.cache.get(server.guildID)
if (!sunucu) return;
if(!sunucu.members.cache.has(memberdata.user)) {
data.deleteOne({user: memberdata.user}, async (err) => {
if(err){ console.log("Silinemedi.") }
})
} else {
let member = sunucu.members.cache.get(memberdata.user)
if (!member) return;
member.roles.remove(server.ChatMuteRole)
data.deleteOne({user: member.id}, async (err) => {
if(err){ console.log("Silinemedi.") }
})
}
});
}, 5000);
}