2020-05-15 07:39:49 +00:00
#!/usr/bin/env node
// Load up the libraries
const Discord = require ( "discord.js" ) ;
const prettyMilliseconds = require ( 'pretty-ms' ) ;
2020-05-25 17:41:39 +00:00
const fs = require ( 'fs' ) ;
2020-05-25 21:23:31 +00:00
const homedir = require ( 'os' ) . homedir ;
const info = require ( "../package.json" )
2020-05-24 19:05:56 +00:00
//importing files
2020-05-24 05:56:39 +00:00
const config = require ( "./config.json" ) ;
2020-05-24 05:26:36 +00:00
// This is making clients
2020-05-15 07:39:49 +00:00
const client = new Discord . Client ( ) ;
2020-05-24 05:56:39 +00:00
2020-05-24 05:26:36 +00:00
2020-05-18 18:51:01 +00:00
function activity ( ) {
client . user . setActivity ( ` ${ client . users . cache . size } of you horrible people ` , { type : 'LISTENING' } ) ;
} ;
2020-05-15 07:39:49 +00:00
client . on ( "ready" , ( ) => {
// This event will run if the bot starts, and logs in, successfully.
console . log ( ` Bot has started, with ${ client . users . cache . size } users, in ${ client . channels . cache . size } channels of ${ client . guilds . cache . size } guilds. ` ) ;
// Example of changing the bot's playing game to something useful. `client.user` is what the
// docs refer to as the "ClientUser".
2020-05-18 18:51:01 +00:00
activity ( ) ;
2020-05-15 07:39:49 +00:00
} ) ;
//Updates people count
2020-04-04 23:01:46 +00:00
client . on ( 'guildMemberAdd' , member => {
console . log ( ` New member joined: ${ member . name } (id: ${ member . id } ). ` ) ;
2020-05-18 18:51:01 +00:00
activity ( ) ;
2020-04-04 23:01:46 +00:00
} ) ;
client . on ( 'guildMemberRemove' , member => {
console . log ( ` member left: ${ member . name } (id: ${ member . id } ). ` ) ;
2020-05-18 18:51:01 +00:00
activity ( ) ;
2020-04-04 23:01:46 +00:00
} ) ;
2020-05-18 18:51:01 +00:00
setInterval ( activity , 300000 ) ;
2020-05-15 07:39:49 +00:00
////// ACTUAL MESSAGE PROCESSING
2020-04-04 23:01:46 +00:00
client . on ( "message" , async message => {
2020-05-15 07:39:49 +00:00
//stops bots from activating the Osselbot
//Message processing
2020-05-27 16:07:17 +00:00
if ( message . content . toLowerCase ( ) . includes ( 'nigg' , "niglet" , "negro" , "fag" , "f4g" , "n1gg" , "gg3r" ) ) {
message . delete ( ) ;
return message . reply ( ` Listen here cum-sock we dont appeciate that here ${ message . member } . If you gonna be like that you may just well end up in the JAR and we all know how that ends... ` )
}
2020-05-15 07:39:49 +00:00
if ( message . author . bot ) return ;
if ( message . content . indexOf ( config . prefix ) !== 0 ) return ;
// Here we separate our "command" name, and our "arguments" for the command.
2020-04-04 23:01:46 +00:00
// e.g. if we have the message "+say Is this the real life?" , we'll get the following:
// command = say
// args = ["Is", "this", "the", "real", "life?"]
2020-05-15 07:39:49 +00:00
const args = message . content . slice ( config . prefix . length ) . trim ( ) . split ( / +/g ) ;
const command = args . shift ( ) . toLowerCase ( ) ;
//////////////////////////////////////////////////////////////////////////////
//COMMAND TIME
//////////////////////////////////////////////////////////////////////////////
if ( command === "reboot" ) {
function shutdown ( ) {
client . destroy ( ) ;
process . exit ( 69 ) ;
}
if ( message . author . id === '216042720047661057' ) {
message . reply ( "**Authenticated**, Restarting now." ) ;
client . user . setActivity ( ` Itself die ` , { type : 'WATCHING' } ) ;
setTimeout ( shutdown , 5000 , 'shutdown' ) ;
2020-04-04 23:01:46 +00:00
}
else {
2020-05-15 07:39:49 +00:00
return message . reply ( "No" ) ;
} ;
2020-04-04 23:01:46 +00:00
} ;
2020-05-15 07:39:49 +00:00
//////////////////////////////////////////////////////////////////////////////
if ( command === "stats" ) {
let embed = new Discord . MessageEmbed ( )
2020-06-14 03:16:58 +00:00
. setTitle ( 'Stats' )
2020-05-18 18:51:01 +00:00
. setAuthor ( "Osselbot" , "https://cdn.discordapp.com/attachments/597814181084921866/711843993914310656/animated-beach-balls-29.gif" )
2020-05-15 07:39:49 +00:00
. setColor ( 0x195080 )
. setDescription ( ` \
* * Stats for 0 SSELB0T * * \ n \
* * Uptime : * * $ { prettyMilliseconds ( client . uptime ) } \ n \
* * Started at : * * $ { client . readyAt } \ n \
2020-05-18 18:51:01 +00:00
* * People : * * $ { client . users . cache . size } ` )
2020-05-25 21:23:31 +00:00
. setFooter ( ` osselbot v ${ info . version } run version for full info ` ) ;
2020-05-15 07:39:49 +00:00
return message . channel . send ( embed ) ;
2020-04-04 23:01:46 +00:00
} ;
2020-05-15 07:39:49 +00:00
//////////////////////////////////////////////////////////////////////////////
if ( command === "ping" ) {
// Calculates ping between sending a message and editing it, giving a nice round-trip latency.
const m = await message . channel . send ( "Ping?" ) ;
m . edit ( ` Pong! Latency is ${ m . createdTimestamp - message . createdTimestamp } ms ` ) ;
2020-04-04 23:01:46 +00:00
} ;
2020-05-15 07:39:49 +00:00
//////////////////////////////////////////////////////////////////////////////
//HOW QUOTEABLE
2020-04-04 23:01:46 +00:00
if ( command === "psych" ) {
return message . channel . send ( "Rules for finding a psychopath: \n1. Favorite color is orange \n2. Likes the left burners, worse if its top left\n3. Calls pizza sauce/tomato sauce gravy\n4. Doesnt like salad\n5. Likes country music\n6. Makes hot chocolate with water\n7. Likes black licorice" )
} ;
2020-05-15 07:39:49 +00:00
if ( command === "ask" ) {
return message . channel . send ( "Dont Ask, Just ask!\n https://iki.fi/sol/dontask.html" )
2020-04-04 23:01:46 +00:00
} ;
2020-05-15 07:39:49 +00:00
2020-04-04 23:01:46 +00:00
if ( command === "simp" ) {
if ( ! message . member . roles . cache . some ( r => [ "Admin" , "Moderator" , "Member of the Order of the b l u e" , "Botmeister" ] . includes ( r . name ) ) )
return message . reply ( "Sorry, you don't have permissions to use this!" ) ;
let embed = new Discord . MessageEmbed ( )
. setTitle ( "SIMP Alert" )
. setURL ( "https://www.youtube.com/watch?v=c3m4Q07TkMk" )
. setColor ( 0x195080 )
. setDescription ( "__**ALERT**__ SIMP detected!" )
. setImage ( "https://vignette.wikia.nocookie.net/disney/images/6/64/Kronk_.jpg/revision/latest?cb=20160720194635" )
. setTimestamp ( )
message . channel . send ( { embed } )
2020-05-15 07:39:49 +00:00
} ;
if ( command === "squad" ) {
2020-05-25 17:41:39 +00:00
min = Math . ceil ( 0 ) ;
2020-05-15 07:39:49 +00:00
max = Math . floor ( 11 ) ;
let rate = Math . floor ( Math . random ( ) * ( max - min ) + min ) ; //The maximum is exclusive and the minimum is inclusive
return message . reply ( ` The squad rates this ${ rate } out of 10 ` ) ;
} ;
if ( command === "magic" ) {
return message . channel . send ( "Do you believe in magic in a young girl\'s heart\nHow the music can free her, whenever it starts\nAnd it\'s magic, if the music is groovy\nIt makes you feel happy like an old-time movie\nI\'ll tell you about the magic, and it\'ll free your soul\nBut it\'s like trying to tell a stranger bout \'rock and roll\'" ) ;
} ;
if ( command === 'help' ) {
return message . reply ( 'https://technicolor.2a03.party/bot/' ) ;
} ;
if ( command === "fix" ) {
if ( message . member . roles . cache . some ( r => [ "Botmeister" ] . includes ( r . name ) ) ) {
return message . channel . send ( "I guess it\'s my fault will fix." ) ;
} ;
return ;
} ;
2020-05-18 07:58:12 +00:00
////////////////////////////////////////////////////////////////////////////////
if ( command === "say" ) {
// makes the bot say something and delete the message. As an example, it's open to anyone to use.
// To get the "message" itself we join the `args` back into a string with spaces:
const sayMessage = args . join ( " " ) ;
2020-05-27 00:23:04 +00:00
if ( message . member . roles . cache . some ( r => [ "Admin" , "Mods" , "Member of the Order" , "Botmeister" , "Ally of the Order" , "say" ] . includes ( r . name ) ) ) { }
2020-05-18 07:58:12 +00:00
// Then we delete the command message (sneaky, right?). The catch just ignores the error with a cute smiley thing.
message . delete ( ) . catch ( O _o => { } ) ;
// And we get the bot to say the thing:
return message . channel . send ( sayMessage ) ;
} ;
2020-05-27 00:23:04 +00:00
2020-05-24 05:26:36 +00:00
////////////////////////////////////////////////////////////////////////////////
if ( command === "quote" ) {
2020-05-26 22:09:56 +00:00
2020-05-26 01:27:26 +00:00
let quotes = require ( ` ${ homedir } /quotes.json ` ) ;
2020-05-25 22:32:35 +00:00
var quoteadd = "" ;
2020-05-26 22:09:56 +00:00
var selector ;
2020-05-25 23:06:00 +00:00
try {
2020-05-26 01:09:55 +00:00
selector = args [ 0 ] . toLowerCase ( ) ;
} catch ( err ) {
var number = quotes . quotes . length + 1 ;
let quotesend = Math . floor ( Math . random ( ) * ( number - 0 ) + 0 ) ;
return message . channel . send ( ` ${ quotes . quotes [ quotesend ] } ` ) ;
} ;
if ( selector === "add" ) {
2020-05-27 00:23:04 +00:00
if ( ! ( message . member . roles . cache . some ( r => [ "Admin" , "Mods" , "Member of the Order" , "Botmeister" , "Ally of the Order" , "say" ] . includes ( r . name ) ) ) ) return message . reply ( "Ask someone with the quote role to add that." )
2020-05-26 01:09:55 +00:00
args . shift ( ) ;
2020-05-26 22:09:56 +00:00
//This does logic to make it from an array to a nice string.
quoteadd = args . join ( ' ' ) ;
quotes . quotes . push ( quoteadd )
2020-05-27 00:04:50 +00:00
fs . writeFile ( ` ${ homedir } /quotes.json ` , JSON . stringify ( quotes , null , 2 ) , ( err ) => {
2020-05-26 01:09:55 +00:00
if ( err ) return message . reply ( "Something went wrong" ) ; ` `
client . channels . cache . get ( '712084662033580064' ) . send ( ` ${ message . member } has submitted \` ${ quoteadd } \` to the quote repository ` ) ;
return message . reply ( "Quote added to repository" ) ;
2020-05-25 23:06:00 +00:00
} ) ;
2020-05-26 01:09:55 +00:00
}
else {
return message . reply ( "you can add quotes by running `?quote add <person> Quote goes here`" ) ;
} ;
2020-05-26 01:24:23 +00:00
} ;
2020-05-18 18:06:35 +00:00
////////////////////////////////////////////////////////////////////////////////
if ( command === "version" ) {
2020-05-25 21:23:31 +00:00
return message . channel . send ( ` \` \` \` \
2020-05-24 05:56:39 +00:00
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \ n \
2020-05-25 21:23:31 +00:00
< @ technicolor - creamsicle / osselbot @ v$ { info . version } > \ n \
2020-05-18 18:06:35 +00:00
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n \
\ \ ^ _ _ ^ \ n \
\ \ ( oo ) \ \ _ _ _ _ _ _ _ \ n \
( _ _ ) \ \ ) \ \ / \ \ \ n \
|| -- -- w | \ n \
|| || \ n \
2020-05-25 21:23:31 +00:00
\ ` \` \` ` )
2020-05-26 01:24:23 +00:00
} ;
2020-05-18 18:06:35 +00:00
2020-05-15 07:39:49 +00:00
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////DEFCON//////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
2020-04-04 23:01:46 +00:00
if ( command === "defcon" ) {
//5 levels till ban
if ( ! message . member . roles . cache . some ( r => [ "Admin" , "Member of the Order of the b l u e" , "Botmeister" ] . includes ( r . name ) ) )
return message . reply ( "Sorry, you don't have permissions to use this!" ) ;
else {
let member = message . mentions . members . first ( ) ;
var role = "" ;
switch ( parseInt ( args [ 1 ] , 10 ) ) {
case 5 :
var role = message . guild . roles . cache . find ( role => role . name === ` DEFCON 5 ` ) ;
member . roles . add ( role ) ;
break ;
case 4 :
var role = message . guild . roles . cache . find ( role => role . name === ` DEFCON 4 ` ) ;
member . roles . add ( role ) ;
2020-05-15 07:39:49 +00:00
break ;
case 3 :
2020-04-04 23:01:46 +00:00
var role = message . guild . roles . cache . find ( role => role . name === ` DEFCON 3 ` ) ;
2020-05-15 07:39:49 +00:00
member . roles . add ( role ) ;
2020-04-04 23:01:46 +00:00
break ;
2020-05-15 07:39:49 +00:00
case 2 :
2020-04-04 23:01:46 +00:00
var role = message . guild . roles . cache . find ( role => role . name === ` DEFCON 2 ` ) ;
member . roles . add ( role ) ;
2020-05-15 07:39:49 +00:00
break ;
case 1 :
2020-04-04 23:01:46 +00:00
var role = message . guild . roles . cache . find ( role => role . name === ` DEFCON 1 ` ) ;
member . roles . add ( role ) ;
2020-05-15 07:39:49 +00:00
break ;
2020-04-04 23:01:46 +00:00
default :
return message . reply ( ` DEFCON not set is ${ args [ 1 ] } a number between 1-5? ` )
} ;
return message . reply ( ` \n **DEFCON** level set to DEFCON ${ args [ 1 ] } \n God Bless their souls ` )
} ;
} ;
} ) ;
2020-05-17 06:59:12 +00:00
if ( process . argv . slice ( 2 ) . includes ( "--TEST" ) ) {
console . log ( "Test Pass!" ) ;
process . exit ( 0 ) ;
} ;
2020-05-15 07:39:49 +00:00
//Logging in the bot
2020-04-04 23:01:46 +00:00
client . login ( config . token )