2018-09-07 00:24:03 +02:00
const { CommandoClient } = require ( 'discord.js-commando' ) ;
const path = require ( 'path' ) ;
2018-09-17 21:17:37 +02:00
const { token , prefix } = require ( './config.json' ) ;
2018-09-07 21:28:42 +02:00
const responseObject = require ( "./reply.json" ) ;
2018-09-08 02:25:58 +02:00
const fs = require ( "fs" ) ;
2018-09-07 00:24:03 +02:00
2018-09-07 21:28:42 +02:00
// Prefix and ownerID and invite to support server
2018-09-07 00:24:03 +02:00
const client = new CommandoClient ( {
2018-09-17 21:17:37 +02:00
commandPrefix : ` ${ prefix } ` ,
2018-09-07 19:07:10 +02:00
owner : '267065637183029248' ,
invite : 'https://discord.gg/SsMCsVY' ,
2018-09-10 18:52:19 +02:00
unknownCommandResponse : false ,
2018-09-17 21:17:37 +02:00
disableEveryone : true ,
2018-09-07 00:24:03 +02:00
} ) ;
2018-09-07 21:28:42 +02:00
// Command groups
2018-09-07 00:24:03 +02:00
client . registry
2018-09-07 19:07:10 +02:00
. registerDefaultTypes ( )
. registerGroups ( [
2018-09-18 02:18:54 +02:00
[ 'fun' , 'Fun' ] ,
[ 'utility' , 'Utility' ] ,
[ 'admin' , 'Admins' ] ,
[ 'owner' , 'Owner' ] ,
2018-09-07 19:07:10 +02:00
] )
. registerDefaultGroups ( )
. registerDefaultCommands ( )
. registerCommandsIn ( path . join ( _ _dirname , 'commands' ) ) ;
2018-09-07 21:28:42 +02:00
// Ready messages
2018-09-08 19:50:01 +02:00
client . on ( 'ready' , ( ) => {
2018-09-09 00:53:08 +02:00
// Send stats to the console
2018-09-07 19:07:10 +02:00
console . log ( ` Logged in as ${ client . user . tag } ! ( ${ client . user . id } ) ` ) ;
2018-09-08 01:55:01 +02:00
console . log ( ` Ready to serve in ${ client . channels . size } channels on ${ client . guilds . size } servers, for a total of ${ client . users . size } users. ${ client . readyAt } ` ) ;
2018-09-17 21:17:37 +02:00
// Send stats to the "stats" channel in the support server if its not the test bot
if ( client . user . id == 377563711927484418 ) {
2018-09-09 00:22:05 +02:00
const channel = client . channels . get ( '487766113292124160' ) ;
channel . send ( ` Ready to serve in ${ client . channels . size } channels on ${ client . guilds . size } servers, for a total of ${ client . users . size } users. ${ client . readyAt } ` ) ;
2018-09-17 21:17:37 +02:00
}
2018-09-17 16:32:27 +02:00
client . user . setActivity ( '"haha help" or "@me help" for help' ) ;
2018-09-08 19:50:01 +02:00
} ) ;
2018-09-09 00:22:05 +02:00
// When bot join a guild send embeds with details about it.
2018-09-08 19:45:42 +02:00
client . on ( "guildCreate" , guild => {
2018-09-08 20:21:08 +02:00
console . log ( ` ${ guild . name } \n ${ guild . memberCount } users \n Owner: ${ guild . owner } ` ) ;
2018-09-08 19:45:42 +02:00
const channel = client . channels . get ( '487766113292124160' ) ;
2018-09-18 02:18:54 +02:00
const addEmbed = {
2018-09-09 00:48:50 +02:00
color : 0x008000 ,
title : 'Someone added the bot! :D YAY' ,
2018-09-08 19:45:42 +02:00
description : ` ${ guild . name } \n ${ guild . memberCount } users \n Owner: ${ guild . owner } ` ,
timestamp : new Date ( ) ,
} ;
2018-09-18 02:18:54 +02:00
channel . send ( { embed : addEmbed } ) ;
2018-09-08 19:45:42 +02:00
} )
2018-09-09 00:22:05 +02:00
// When bot get kicked from a guild send embeds with details about it.
2018-09-09 00:05:14 +02:00
client . on ( "guildDelete" , guild => {
2018-09-08 23:34:08 +02:00
console . log ( ` ***BOT KICKED*** \n ${ guild . name } \n ${ guild . memberCount } users \n Owner: ${ guild . owner } \n ***BOT KICKED*** ` ) ;
const channel = client . channels . get ( '487766113292124160' ) ;
2018-09-18 02:18:54 +02:00
const kickEmbed = {
2018-09-09 00:48:50 +02:00
color : 0xFF0000 ,
2018-09-09 16:32:33 +02:00
title : 'Someone removed the bot :(' ,
2018-09-08 23:34:08 +02:00
description : ` ${ guild . name } \n ${ guild . memberCount } users \n Owner: ${ guild . owner } ` ,
timestamp : new Date ( ) ,
} ;
2018-09-18 02:18:54 +02:00
channel . send ( { embed : kickEmbed } ) ;
2018-09-08 23:34:08 +02:00
} )
2018-09-07 21:28:42 +02:00
// Auto respond to messages
2018-09-17 22:07:32 +02:00
client . on ( "message" , ( message ) => {
2018-09-18 01:40:27 +02:00
let message _content = message . content . toLowerCase ( ) ;
if ( responseObject [ message _content ] ) {
message . channel . send ( responseObject [ message _content ] ) ;
2018-09-17 22:07:32 +02:00
}
} ) ;
2018-09-08 01:37:16 +02:00
2018-09-07 19:07:10 +02:00
client . on ( 'error' , console . error ) ;
2018-09-07 00:24:03 +02:00
2018-09-07 19:07:10 +02:00
client . login ( token ) ;