2017-08-14 15:41:55 -04:00
const Discord = require ( 'discord.js' ) ;
2017-08-17 17:45:26 -04:00
const profanities = require ( 'profanities' ) ;
2017-08-14 15:41:55 -04:00
const client = new Discord . Client ( ) ;
const config = require ( './absettings.json' ) ;
client . on ( 'ready' , ( ) => {
console . log ( "[SUCCESS] AleeArmy Welcomer is now ready!" ) ;
client . user . setStatus ( 'invisible' )
} ) ;
client . on ( "guildMemberAdd" , function ( member ) {
2017-08-14 23:01:34 -04:00
member . guild . channels . find ( "name" , "welcomes-and-byes" ) . sendMessage ( member . toString ( ) + " has joined the server" )
2017-08-20 16:56:29 -04:00
message . author . sendMessage ( ` Welcome to the AleeArmy Server ** ${ member . user . username } **! Make sure to read the rules first and wait until Alee or a staff makes you part of member! ` ) ;
2017-08-14 15:41:55 -04:00
} ) ;
client . on ( "guildMemberRemove" , function ( member ) {
2017-08-17 23:33:05 -04:00
member . guild . channels . find ( "name" , "welcomes-and-byes" ) . sendMessage ( ` ** ${ member . user . username } ** has left the server ` ) ;
2017-08-14 15:41:55 -04:00
} ) ;
2017-08-17 17:45:26 -04:00
client . on ( 'message' , message => {
for ( x = 0 ; x < profanities . length ; x ++ ) {
if ( message . content . toUpperCase ( ) == profanities [ x ] . toUpperCase ( ) ) {
2017-08-20 16:56:29 -04:00
client . channels . get ( '318874545593384970' ) . sendMessage ( ":information_source: **" + message . author . username + "** just swore in #" + message . channel . name + "!" ) ;
2017-08-17 20:22:53 -04:00
console . log ( '[WARNING] ' + message . author . username + ' just swore in #' + message . channel . name + '!' )
2017-08-17 18:11:36 -04:00
switch ( Math . floor ( Math . random ( ) * 1000 ) % 3 ) {
case 0 :
message . reply ( 'Keep this server clean buddy!' ) ;
break ;
case 1 :
message . reply ( 'We want this server PG!' ) ;
break ;
case 2 :
message . reply ( 'Hmm. You like swearing a lot well some other people don\'t!' )
break ;
2017-08-17 20:18:03 -04:00
case 3 :
message . reply ( "If you like swearing say it in your head please." )
2017-08-17 18:11:36 -04:00
}
2017-08-17 17:45:26 -04:00
message . delete ( ) ;
return ;
}
}
} ) ;
2017-08-14 15:41:55 -04:00
process . on ( 'unhandledRejection' , function ( err , p ) {
console . log ( "[ERROR | UNCAUGHT PROMISE] " + err . stack ) ;
} ) ;
2017-08-14 15:46:25 -04:00
client . login ( config . aawtoken ) . catch ( function ( ) {
2017-08-14 15:41:55 -04:00
console . log ( "[ERROR] Login failed. Please contact Alee14#9928 or email him at alee14498@gmail.com." ) ;
} ) ;