@ -413,7 +413,8 @@ const ErrorType =
Arguments : "Arguments" ,
Arguments : "Arguments" ,
NoArguments : "No Arguments Given" ,
NoArguments : "No Arguments Given" ,
NotOnTheList : "Unknown Command" ,
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 ;
module . exports . ErrorType = ErrorType ;
@ -496,6 +497,10 @@ class ErrorMessage
case ErrorType . OldMessages :
case ErrorType . OldMessages :
embed . data . fields [ 0 ] . value = ErrorType . OldMessages ;
embed . data . fields [ 0 ] . value = ErrorType . OldMessages ;
break ;
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 :
default :
break ;
break ;
}
}
@ -1246,41 +1251,62 @@ class Strikes
} , 5 * 60 * 1000 ) ;
} , 5 * 60 * 1000 ) ;
//TODO: Handle old strikes
//TODO: Handle old strikes
//* Strikes life time should be difined by guild
/ * *
//* A default should be set
* db . strikes . createIndex ( { expireAt : 1 } , { expireAfterSeconds : 0 } )
//? 15 days
* 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 ( )
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 } ) ;
* TODO : Grab validated strikes .
if ( ! guilds ) return console . log ( 'Striker: No Guilds' )
* TODO : Check if guild has strikes active .
var guildIds = [ ] ;
* TODO : Handle player if strikes have reached the threshold
for ( var i = 0 ; i < guilds . length ; i ++ )
* TODO : X
{
*
guildIds . push ( guilds [ i ] . gID ) ;
* /
}
var filtered = Strikes . filter (
// const Strikes = await strikesM.find().then(s=>{return s});
( e ) => {
// //console.log(Strikes);
return guildIds . indexOf ( e . guildID ) >= 0 ;
// const guilds = await guildsM.find({strikes:true}).then(g=>{return g});
}
// if(!guilds) return console.log('Striker: No Guilds')
)
// var guildIds = [];
guildIds . forEach ( guild =>
// for(var i = 0; i<guilds.length; i++)
{
// {
filtered . forEach ( strike =>
// guildIds.push(guilds[i].gID);
{
// }
( async ( guild , strike ) =>
// var filtered = Strikes.filter(
{
// (e) => {
const ammount = await strikesM . find ( { guildID : guild , strokedID : strike . strokedID } ) . then ( res => { return res . length } ) ;
// return guildIds.indexOf(e.guildID)>=0;
if ( ammount > 2 )
// }
{
// )
this . handleStroked ( strike . strokedID , guild ) ;
// guildIds.forEach(guild=>
}
// {
} ) ( guild , strike )
// 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 )
handleStroked ( user , guild )
{
{
@ -1295,4 +1321,5 @@ class Strikes
. 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 ;