Функция UnBan:
async function unBan(id, chatid) {
await mongo.models.chatsusers.updateOne({ vkid: Number(id), join_chat: Number(chatid), banned: String(true) }, { $set: { banned: false, bannedTime: "None", bannedReason: "None" } })
}
Таймер:
let timeValue = `1`
let timeUnit = `день`
let seconds = convertToSeconds(timeValue, timeUnit)
let secondsToMilSeconds = seconds * 1000
let chatid = message.chatId
setTimeout(() => {
unBan(id, chatid)
}, secondsToMilSeconds);
Если кому надо то вот функция convertToSeconds:
function convertToSeconds(timeValue, timeUnit) {
switch (timeUnit) {
case 'день':
return timeValue * 24 * 60 * 60;
case 'час':
return timeValue * 60 * 60;
case 'минута':
return timeValue * 60;
default:
return 0;
}
}