2017-05-31 16:26:45 -04:00
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2017-07-29 15:46:00 -04:00
*
2017-07-26 19:13:04 -04:00
* AleeBot for AleeArmy Community and other servers
* Copyright ( C ) 2017 AleeCorp
2017-05-31 16:26:45 -04:00
*
2017-08-13 20:59:45 -04:00
* Permission is hereby granted , free of charge , to any person obtaining a copy
* of this software and associated documentation files ( the "Software" ) , to deal
* in the Software without restriction , including without limitation the rights
* to use , copy , modify , merge , publish , distribute , sublicense , and / or sell
* copies of the Software , and to permit persons to whom the Software is
* furnished to do so , subject to the following conditions :
2017-07-29 15:46:00 -04:00
*
2017-08-13 20:59:45 -04:00
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software .
*
* THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR
* IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY ,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER
* LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM ,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE .
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2017-05-31 16:09:24 -04:00
const Discord = require ( 'discord.js' ) ;
const client = new Discord . Client ( ) ;
2017-07-29 17:57:02 -04:00
const config = require ( './absettings.json' ) ;
2017-07-29 15:46:00 -04:00
2017-08-14 00:14:47 -04:00
var prefix = "ab:" ;
2017-08-05 17:28:18 -04:00
const year = "2017" ;
2017-08-13 22:40:38 -04:00
var abversion = "1.0.8.5" ;
2017-07-26 14:10:01 -07:00
var logsChannel = "318874545593384970" ;
2017-07-27 15:21:37 -04:00
client . on ( 'ready' , ( ) => {
2017-07-31 18:41:32 -04:00
console . log ( "[SUCCESS] AleeBot is now ready! Running version " + abversion + "!" ) ;
2017-07-31 18:51:04 -04:00
client . user . setGame ( ` on ${ client . guilds . size } servers ` ) ;
2017-08-04 20:30:24 -04:00
client . user . setStatus ( 'online' )
2017-07-27 15:21:37 -04:00
} ) ;
2017-08-04 20:30:24 -04:00
2017-08-13 19:35:12 -04:00
client . on ( "guildMemberAdd" , function ( member ) {
member . guild . channels . find ( "name" , "welcomes-and-byes" ) . sendMessage ( member . toString ( ) + " has joined the server" ) ;
2017-07-28 21:51:53 -04:00
} ) ;
2017-07-27 15:21:37 -04:00
2017-08-13 19:35:12 -04:00
client . on ( "guildMemberRemove" , function ( member ) {
member . guild . channels . find ( "name" , "welcomes-and-byes" ) . sendMessage ( member . toString ( ) + " has left the server" ) ;
2017-08-03 22:49:47 -04:00
} ) ;
2017-07-29 15:46:00 -04:00
2017-08-03 22:54:01 -04:00
/ *
2017-07-26 14:10:01 -07:00
function wordFilter ( content ) {
var word = content . search ( /\b(fuck|fag|faggot|fuck|fuk|fuc|fucc|ho|phuck|hentai|porn|slut|bitch|succ|fucking|shit|ass|asshole|mofo|motherfucker|fucker|damn|hell|dick|cock|sex|cunt|nigger|nigga)+\b/i ) ;
2017-07-29 15:46:00 -04:00
2017-07-26 14:10:01 -07:00
if ( word != - 1 ) {
return true ;
} else {
return false ;
}
2017-07-27 12:22:34 -04:00
} * /
2017-06-01 22:26:22 +00:00
2017-07-31 16:46:27 -04:00
client . on ( "guildCreate" , guild => {
// This event triggers when the bot joins a guild.
console . log ( ` New guild joined: ${ guild . name } (id: ${ guild . id } ). This guild has ${ guild . memberCount } members! ` ) ;
client . user . setGame ( ` on ${ client . guilds . size } servers ` ) ;
2017-08-12 00:42:28 -04:00
guild . defaultChannel . sendMessage ( ":wave: Hello I am AleeBot thanks for inviting me to your server for help type `ab:help`." )
2017-07-31 16:46:27 -04:00
} ) ;
client . on ( "guildDelete" , guild => {
// this event triggers when the bot is removed from a guild.
console . log ( ` I have been removed from: ${ guild . name } (id: ${ guild . id } ) ` ) ;
client . user . setGame ( ` on ${ client . guilds . size } servers ` ) ;
} ) ;
2017-07-26 14:10:01 -07:00
client . on ( "message" , function ( message ) {
2017-07-29 16:31:10 -04:00
if ( message . author . bot ) return ;
if ( ! message . content . startsWith ( prefix ) ) return ;
let command = message . content . split ( " " ) [ 0 ] ;
command = command . slice ( prefix . length ) ;
let args = message . content . split ( " " ) . slice ( 1 ) ;
2017-07-27 12:22:34 -04:00
/ * i f ( w o r d F i l t e r ( m e s s a g e . c o n t e n t ) )
2017-07-26 14:10:01 -07:00
{
message . delete ( ) ;
client . channels . get ( '318874545593384970' ) . sendMessage ( ":information_source: " + message . author . username + " just swore!" ) ;
console . log ( "[INFO] " + message . author . username + " just swore!" ) ;
switch ( Math . floor ( Math . random ( ) * 1000 ) % 3 ) {
message . reply ( "You have been caught swearing." ) ;
message . author . send ( "You have been caught swearing in AleeArmy Community." ) ;
2017-07-27 12:22:34 -04:00
} * /
2017-07-29 15:46:00 -04:00
2017-07-29 16:31:10 -04:00
if ( command === 'help' ) {
2017-07-29 00:19:15 -04:00
var embed = new Discord . RichEmbed ( )
2017-08-13 01:49:47 -04:00
. setTitle ( 'Commands for AleeBot ' + abversion )
2017-08-14 00:38:35 -04:00
. setDescription ( 'Every command you put in this bot must start with ' + prefix )
2017-08-13 15:07:11 -04:00
. addField ( 'Fun Stuff:' , 'attack\nask\nship' , true )
2017-08-13 15:39:16 +00:00
. addField ( 'Info:' , 'userinfo\nserverinfo' , true )
. addField ( 'Link:' , 'botinvite\nserverinvite\ngit' , true )
. addField ( 'Owner Only:' , 'say\neval' , true )
. addField ( 'Monitor:' , 'ping\nuptime' , true )
2017-08-14 02:08:38 -04:00
. addField ( 'Etc:' , 'avatarurl\nsuggest\nplan' , true )
2017-08-13 02:00:17 -04:00
. setFooter ( "AleeBot " + abversion + " Copyright " + year + ". Created By Alee14" , "https://cdn.discordapp.com/avatars/282547024547545109/6c147a444ae328c38145ef1f74169e38.png?size=2048" )
2017-07-31 17:07:33 -04:00
. setColor ( "#7af442" )
2017-07-29 00:19:15 -04:00
message . channel . sendEmbed ( embed ) ;
2017-08-13 15:54:04 +00:00
message . delete ( ) ;
2017-07-31 16:46:27 -04:00
2017-07-28 22:37:47 -04:00
}
2017-07-29 15:46:00 -04:00
2017-08-13 17:09:00 -04:00
if ( command === 'avatarurl' ) {
2017-06-01 22:26:22 +00:00
message . reply ( message . author . avatarURL ) ;
}
2017-07-29 16:31:10 -04:00
if ( command === 'git' ) {
2017-08-13 02:23:13 -04:00
message . channel . send ( "Here's the github repo: https://github.com/AleeCorp/AleeBot" ) ;
2017-06-01 22:26:22 +00:00
}
2017-07-29 16:31:10 -04:00
if ( command === 'ping' ) {
2017-08-13 15:48:29 -04:00
message . reply ( "**PONG!** :ping_pong: " + Math . round ( client . ping ) + " ms" ) ;
2017-06-01 22:26:22 +00:00
}
2017-07-29 16:31:10 -04:00
if ( command === 'suggest' ) {
2017-06-06 20:18:46 +00:00
message . reply ( 'Sorry this feature is still being worked on :(' ) ;
}
2017-07-29 15:46:00 -04:00
2017-08-11 16:08:16 -04:00
if ( command === 'uptime' ) {
2017-08-12 02:07:42 -04:00
//This command was ported from AstralMod
2017-08-11 16:08:16 -04:00
var timeString ; // What we'll eventually put into the message
var uptime = parseInt ( client . uptime ) ; // Get uptime in ms
uptime = Math . floor ( uptime / 1000 ) ; // Convert from ms to s
var uptimeMinutes = Math . floor ( uptime / 60 ) ; // Get the uptime in minutes
var minutes = uptime % 60 ;
var hours = 0 ;
while ( uptimeMinutes >= 60 ) {
hours ++ ;
uptimeMinutes = uptimeMinutes - 60 ;
}
if ( uptimeMinutes < 10 ) {
timeString = hours + ":0" + uptimeMinutes // We need to add an additional 0 to the minutes
} else {
timeString = hours + ":" + uptimeMinutes // We don't need to add an extra 0.
}
message . reply ( ":clock1: AleeBot has been up for " + timeString + " hours." ) ;
commandProcessed = true ;
}
2017-07-29 20:51:13 -04:00
if ( command === 'userinfo' ) {
2017-08-13 12:53:49 -04:00
var embed = new Discord . RichEmbed ( )
. setAuthor ( message . author . username )
. setDescription ( "This is your user info!" )
. setColor ( "#7af442" )
. addField ( "Username" , ` ${ message . author . username } # ${ message . author . discriminator } ` )
. addField ( "Created At" , message . author . createdAt )
message . channel . sendEmbed ( embed ) ;
2017-07-29 20:51:13 -04:00
}
2017-07-26 14:10:01 -07:00
2017-07-29 20:51:13 -04:00
if ( command === 'serverinfo' ) {
var embed = new Discord . RichEmbed ( )
. addField ( "Coming soon!" )
2017-07-31 17:07:33 -04:00
. setColor ( "#7af442" )
2017-07-29 20:51:13 -04:00
message . channel . sendEmbed ( embed ) ;
}
2017-07-30 20:21:18 -04:00
2017-08-11 19:40:09 -04:00
if ( command === 'botinvite' ) {
2017-08-01 15:32:56 -04:00
message . reply ( ':arrow_left: Continue in DMs.' ) ;
2017-07-31 16:46:27 -04:00
message . author . sendMessage ( "AleeBot on your server? Great! Here's the link: https://goo.gl/KDQyrp" ) ;
2017-07-30 20:21:18 -04:00
}
2017-07-30 20:28:55 -04:00
if ( command === 'serverinvite' ) {
2017-08-01 15:32:56 -04:00
message . reply ( ':arrow_left: Continue in DMs.' ) ;
2017-07-31 16:46:27 -04:00
message . author . sendMessage ( "You want a invite to the AleeArmy server? Here's the link: https://discord.gg/JqgXrAJ" ) ;
2017-07-31 16:48:34 -04:00
2017-08-12 00:21:14 -04:00
}
2017-07-31 00:39:23 -04:00
2017-08-14 02:08:38 -04:00
if ( command === 'plan' ) {
message . channel . send ( '```Plans for future versions of AleeBot\n\n' +
'1. AI\n' +
'2. Playing Music\n' +
"3. Error Handler\n```" ) ;
2017-07-31 16:46:27 -04:00
}
2017-08-14 00:08:17 -04:00
if ( message . content == 'AleeBot sucks' ) {
2017-08-11 17:23:46 -04:00
switch ( Math . floor ( Math . random ( ) * 1000 ) % 3 ) {
case 0 :
message . reply ( 'Why you hate me .-.' ) ;
break ;
case 1 :
message . reply ( 'Okay but why you hate me?' ) ;
break ;
}
}
2017-08-12 00:21:14 -04:00
if ( command === 'attack' ) {
2017-08-12 02:07:42 -04:00
//This command was ported from AstralMod
2017-08-12 00:21:14 -04:00
2017-08-13 23:08:55 -04:00
if ( command . indexOf ( "@everyone" ) == - 1 ) {
2017-08-12 00:21:14 -04:00
2017-08-13 23:08:55 -04:00
if ( command . indexOf ( "@here" ) == - 1 ) {
2017-08-12 00:21:14 -04:00
2017-08-13 02:39:32 -04:00
message . channel . send ( "<@" + message . author . id + "> :right_facing_fist: " + args ) ;
2017-08-12 00:21:14 -04:00
} else {
message . reply ( "Nice try, but I ain't going to interrupt everyone who is online at this time. Kinda nice to not be bothered." ) ;
}
} else {
message . reply ( "Nice try, but I ain't going to interrupt everyone. Kinda nice to not be bothered." ) ;
}
2017-08-02 19:33:30 -04:00
2017-08-12 00:21:14 -04:00
commandProcessed = true ;
}
2017-08-12 02:31:13 -04:00
if ( command === 'ask' ) {
var abaskanswer = [
"Yes." ,
"No." ,
"Maybe." ,
2017-08-12 20:50:25 -04:00
"I don't know?" ,
"Hmm let me think :thinking:" ,
2017-08-14 01:37:31 -04:00
"Sorry my brain can't handle right now :/" ,
2017-08-14 01:20:37 -04:00
":red_circle: ERROR 3029131 OVERFLOW!!!! *explodes*"
2017-08-12 02:31:13 -04:00
] ;
if ( args [ 1 ] ) {
message . channel . sendMessage ( abaskanswer [ Math . floor ( Math . random ( ) * abaskanswer . length ) ] ) ;
} else {
message . channel . sendMessage ( "Sorry, I don't know what your saying." )
}
}
2017-08-12 18:41:21 -04:00
// Owner is only allow to do this
2017-08-12 11:21:09 -04:00
if ( command === 'say' ) {
2017-08-12 18:41:21 -04:00
if ( message . author . id !== config . ownerID ) return ;
2017-08-12 11:21:09 -04:00
message . channel . sendMessage ( args . join ( " " ) ) ;
2017-08-12 11:28:14 -04:00
message . delete ( ) ;
2017-08-12 18:41:21 -04:00
2017-08-12 11:21:09 -04:00
}
2017-08-12 14:02:47 -04:00
if ( command === 'eval' ) {
2017-08-12 14:26:00 -04:00
if ( message . author . id !== config . ownerID ) return ;
2017-08-13 21:34:56 -04:00
const argseval = message . content . split ( " " ) . slice ( 1 ) ;
try {
var code = argseval . join ( " " ) ;
var evaled = eval ( code ) ;
if ( typeof evaled !== "string" )
evaled = require ( "util" ) . inspect ( evaled ) ;
message . delete ( ) ;
message . channel . send ( {
embed : {
color : 3191350 ,
author : {
name : "Eval is working!" ,
icon _url : message . author . displayAvatarURL
} ,
fields : [ {
name : '**:inbox_tray: Input**' ,
value : ` \` \` \` js \n ${ code } \n \` \` \` `
} ,
{
name : '**:outbox_tray: Output**' ,
value : ` \` \` \` js \n ${ clean ( evaled ) } \n \` \` \` `
}
] ,
}
} )
} catch ( err ) {
message . delete ( ) ;
message . channel . send ( {
embed : {
color : 3191350 ,
author : {
name : "Error" ,
icon _url : message . author . displayAvatarURL
} ,
fields : [ {
name : '**Please check your code.**' ,
value : ` \` \` \` xl \n ${ clean ( err ) } \n \` \` \` `
} ,
{
name : '**Output**' ,
value : ` \` \` \` js \n ${ clean ( evaled ) } \n \` \` \` `
}
] ,
}
} )
}
2017-08-12 14:02:47 -04:00
}
2017-08-13 00:31:42 -04:00
if ( command === 'ship' ) {
message . channel . send ( ":ship: " + message . author . username + " x " + message . guild . members . random ( ) . displayName ) ;
2017-08-14 01:59:56 -04:00
}
2017-08-13 21:14:57 -04:00
2017-06-06 20:18:46 +00:00
} ) ;
2017-06-01 22:26:22 +00:00
2017-08-12 14:02:47 -04:00
const clean = text => {
if ( typeof ( text ) === "string" )
return text . replace ( /`/g , "`" + String . fromCharCode ( 8203 ) ) . replace ( /@/g , "@" + String . fromCharCode ( 8203 ) ) ;
else
return text ;
}
2017-07-30 20:21:18 -04:00
process . on ( 'unhandledRejection' , function ( err , p ) {
2017-07-29 21:42:13 -04:00
console . log ( "[ERROR | UNCAUGHT PROMISE] " + err . stack ) ;
} ) ;
2017-07-29 15:46:00 -04:00
2017-06-01 19:59:50 +00:00
client . login ( config . token ) . catch ( function ( ) {
2017-07-27 15:59:49 -04:00
console . log ( "[ERROR] Login failed. Please contact Alee14#9928 or email him at alee14498@gmail.com." ) ;
2017-05-31 16:09:24 -04:00
} ) ;