diff --git a/lib.js b/lib.js index 73bbd83..0b97338 100644 --- a/lib.js +++ b/lib.js @@ -1250,18 +1250,6 @@ class Strikes setInterval(() => { this.check(); }, 5*60*1000); - - //TODO: Handle old strikes - /** - * db.strikes.createIndex({expireAt:1}, {expireAfterSeconds:0}) - * db.strikes.insertOne( - * {whatever data it takes, - * ! expireAt:new Date(new Date().getTime() + 60000) - * }) - * - * - */ - } async getAreStrikesActive(guildId) { @@ -1275,51 +1263,48 @@ class Strikes * TODO: Grab validated strikes. * TODO: Check if guild has strikes active. * TODO: Handle player if strikes have reached the threshold - * TODO: X * */ - - // const Strikes = await strikesM.find().then(s=>{return s}); - // //console.log(Strikes); - // const guilds = await guildsM.find({strikes:true}).then(g=>{return g}); - // if(!guilds) return console.log('Striker: No Guilds') - // var guildIds = []; - // for(var i = 0; i { - // return guildIds.indexOf(e.guildID)>=0; - // } - // ) - // guildIds.forEach(guild=> - // { - // filtered.forEach(strike=> - // { - // (async (guild, strike)=> - // { - // const ammount = await strikesM.find({guildID:guild, strokedID:strike.strokedID}).then(res=>{return res.length}); - // if(ammount>2) - // { - // this.handleStroked(strike.strokedID, guild); - // } - // })(guild, strike) - // }) - // }) + const Strikes = await strikesM.find().then(s=>{return s}); + const guilds = await guildsM.find({strikes:true}).then(g=>{return g}); + if(!guilds) return console.log('Lib: Striker: No Guilds') + var guildIds = []; + for(var i = 0; i { + return guildIds.indexOf(e.guildID)>=0; + } + ) + guildIds.forEach(guild=> + { + filtered.forEach(strike=> + { + (async (guild, strike)=> + { + const ammount = await strikesM.find({guildID:guild, strokedID:strike.strokedID, validated:true}).then(res=>{return res.length}); + if(ammount>2) + { + this.handleStroked(strike.strokedID, guild); + } + })(guild, strike) + }) + }) } handleStroked(user, guild) { strikesM.deleteMany({ guildID: guild, strokedID: user }, (err, res) => { - if (!err) return console.log('Strikes Deleted') + if (!err) return console.log('Lib: Strikes: Deleted: From User:', user, 'on Guild:', guild) }); // If the user is found, kick them from the server const member = this.client.guilds.cache.get(guild).members.cache.get(user); - if (!member) return console.log('Strikes: Handle Strikened: Member not valid') + if (!member) return console.log('Lib:Strikes: Handle Struck: Member not valid') console.log(member.user.username) - member.kick('Optional reason that will be displayed in the audit logs') - .then(() => console.log(`Successfully kicked ${user.user.username}`)) - .catch(err => console.log(`Unable to kick ${user.user.username}: ${err}`)); + // member.kick('Optional reason that will be displayed in the audit logs') + // .then(() => console.log(`Successfully kicked ${user.user.username}`)) + // .catch(err => console.log(`Unable to kick ${user.user.username}: ${err}`)); } } module.exports.Strikes = Strikes;