Fixed expiration handlers

This commit is contained in:
rainbow napkin 2025-04-27 20:39:47 -04:00
parent 853f67fe15
commit 730d816c45
5 changed files with 44 additions and 19 deletions

View file

@ -318,16 +318,23 @@ channelSchema.statics.reqPermCheck = function(perm, chanField = "chanName"){
channelSchema.statics.processExpiredBans = async function(){
const chanDB = await this.find({});
chanDB.forEach((channel) => {
channel.banList.forEach(async (ban, i) => {
for(let chanIndex in chanDB){
//Pull channel from channels by index
const channel = chanDB[chanIndex];
//channel.banList.forEach(async (ban, banIndex) => {
for(let banIndex in channel.banList){
//Pull ban from channel ban list
const ban = channel.banList[banIndex];
//ignore permanent and non-expired bans
if(ban.expirationDays >= 0 && ban.getDaysUntilExpiration() <= 0){
//Get the index of the ban
channel.banList.splice(i,1);
return await channel.save();
channel.banList.splice(banIndex,1);
await channel.save();
}
})
});
}
}
}
//methods