Stop Strikes self-actinability on Prod

master
masterhc 1 year ago
parent 257ad11bf3
commit e9b5da1698

@ -1250,18 +1250,6 @@ class Strikes
setInterval(() => { setInterval(() => {
this.check(); this.check();
}, 5*60*1000); }, 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) async getAreStrikesActive(guildId)
{ {
@ -1275,51 +1263,48 @@ class Strikes
* TODO: Grab validated strikes. * TODO: Grab validated strikes.
* TODO: Check if guild has strikes active. * TODO: Check if guild has strikes active.
* TODO: Handle player if strikes have reached the threshold * TODO: Handle player if strikes have reached the threshold
* TODO: X
* *
*/ */
const Strikes = await strikesM.find().then(s=>{return s});
// const Strikes = await strikesM.find().then(s=>{return s}); const guilds = await guildsM.find({strikes:true}).then(g=>{return g});
// //console.log(Strikes); if(!guilds) return console.log('Lib: Striker: No Guilds')
// const guilds = await guildsM.find({strikes:true}).then(g=>{return g}); var guildIds = [];
// if(!guilds) return console.log('Striker: No Guilds') for(var i = 0; i<guilds.length; i++)
// var guildIds = []; {
// for(var i = 0; i<guilds.length; i++) guildIds.push(guilds[i].gID);
// { }
// guildIds.push(guilds[i].gID); var filtered = Strikes.filter(
// } (e) => {
// var filtered = Strikes.filter( return guildIds.indexOf(e.guildID)>=0;
// (e) => { }
// return guildIds.indexOf(e.guildID)>=0; )
// } guildIds.forEach(guild=>
// ) {
// guildIds.forEach(guild=> filtered.forEach(strike=>
// { {
// filtered.forEach(strike=> (async (guild, strike)=>
// { {
// (async (guild, strike)=> const ammount = await strikesM.find({guildID:guild, strokedID:strike.strokedID, validated:true}).then(res=>{return res.length});
// { if(ammount>2)
// const ammount = await strikesM.find({guildID:guild, strokedID:strike.strokedID}).then(res=>{return res.length}); {
// if(ammount>2) this.handleStroked(strike.strokedID, guild);
// { }
// this.handleStroked(strike.strokedID, guild); })(guild, strike)
// } })
// })(guild, strike) })
// })
// })
} }
handleStroked(user, guild) handleStroked(user, guild)
{ {
strikesM.deleteMany({ guildID: guild, strokedID: user }, (err, res) => { 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 // If the user is found, kick them from the server
const member = this.client.guilds.cache.get(guild).members.cache.get(user); 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) console.log(member.user.username)
member.kick('Optional reason that will be displayed in the audit logs') // member.kick('Optional reason that will be displayed in the audit logs')
.then(() => console.log(`Successfully kicked ${user.user.username}`)) // .then(() => console.log(`Successfully kicked ${user.user.username}`))
.catch(err => console.log(`Unable to kick ${user.user.username}: ${err}`)); // .catch(err => console.log(`Unable to kick ${user.user.username}: ${err}`));
} }
} }
module.exports.Strikes = Strikes; module.exports.Strikes = Strikes;

Loading…
Cancel
Save