@ -413,7 +413,8 @@ const ErrorType =
Arguments : "Arguments" ,
NoArguments : "No Arguments Given" ,
NotOnTheList : "Unknown Command" ,
OldMessages : "Can't delete this messages."
OldMessages : "Can't delete this messages." ,
FeatureInnactive : "This feature is not active."
}
module . exports . ErrorType = ErrorType ;
@ -496,6 +497,10 @@ class ErrorMessage
case ErrorType . OldMessages :
embed . data . fields [ 0 ] . value = ErrorType . OldMessages ;
break ;
case ErrorType . FeatureInnactive :
embed . data . fields [ 0 ] . value = ErrorType . FeatureInnactive ;
embed . data . fields [ 1 ] . value = 'If you are an admin you can activate the function on the dashboard. (rem.wordfights.com)'
break ;
default :
break ;
}
@ -1246,41 +1251,62 @@ class Strikes
} , 5 * 60 * 1000 ) ;
//TODO: Handle old strikes
//* Strikes life time should be difined by guild
//* A default should be set
//? 15 days
/ * *
* db . strikes . createIndex ( { expireAt : 1 } , { expireAfterSeconds : 0 } )
* db . strikes . insertOne (
* { whatever data it takes ,
* ! expireAt : new Date ( new Date ( ) . getTime ( ) + 60000 )
* } )
*
*
* /
}
async getAreStrikesActive ( guildId )
{
const flag = await guildsM . find ( { gID : guildId } ) . then ( g => { return g . strikes } ) ;
if ( ! flag ) return false ;
return true ;
}
async check ( )
{
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 < guilds . length ; i ++ )
{
guildIds . push ( guilds [ i ] . gID ) ;
}
var filtered = Strikes . filter (
( e ) => {
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 )
} )
} )
/ * *
* 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<guilds.length; i++)
// {
// guildIds.push(guilds[i].gID);
// }
// var filtered = Strikes.filter(
// (e) => {
// 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)
// })
// })
}
handleStroked ( user , guild )
{
@ -1295,4 +1321,5 @@ class Strikes
. then ( ( ) => console . log ( ` Successfully kicked ${ user . user . username } ` ) )
. catch ( err => console . log ( ` Unable to kick ${ user . user . username } : ${ err } ` ) ) ;
}
}
}
module . exports . Strikes = Strikes ;