33 6/24/2021
44
55 Now open-source!
6+
67 Can you believe it took Matt 4 years (as of 2022)
78 to open-source his bot projects?
89 Yeah, I know crazy. wait.. why am I talking third-person again?
@@ -17,8 +18,9 @@ async function bot(debug, lastMessageID = null) {
1718
1819
1920 // ========== PRE-BOOT
21+ var startTime = new Date ( ) . getTime ( ) ;
2022 if ( debug ) console . log ( "- PRE-BOOT" ) ;
21- if ( debug ) console . log ( ` -- App is starting as of ${ new Date ( ) . toString ( ) } -- ` ) ;
23+ if ( debug ) console . log ( ` -- App is starting as of ${ new Date ( startTime ) . toString ( ) } -- ` ) ;
2224
2325 // Change directory
2426 try {
@@ -39,12 +41,14 @@ async function bot(debug, lastMessageID = null) {
3941 logger = new Log ( ) ;
4042 logger . info ( "SYS" , `Logging is now enabled!` ) ;
4143
44+ await logger . warnAboutDebug ( debug ) ; // warn about debugging (if it applies)
4245
4346 if ( debug ) console . log ( "-> Init: App" ) ;
4447 const app = require ( "./app/cfg/app.js" ) ;
4548 app . debugMode = debug ;
4649 app . logger = logger ;
4750 app . bootloader = bootloader ;
51+ app . startTime = startTime ;
4852 app . botStart = ( lastMessage ) => bot ( debug , lastMessage ) ;
4953 if ( lastMessageID != null ) app . lastMessageID = lastMessageID ;
5054 logger . info ( "SYS" , `App core successfully loaded!` ) ;
@@ -80,12 +84,13 @@ async function bot(debug, lastMessageID = null) {
8084 log ( 'X' , 'SYS' , err ) ;
8185 } ;
8286
83- var events = Object . keys ( app . client . _events )
84- if ( events )
87+ if ( app . client . _events ) {
88+ var events = Object . keys ( app . client . _events )
8589 for ( var i = 0 ; i < events . length ; i ++ ) {
8690 log ( "i" , "SYS" , "Unloading event " + events [ i ] ) ;
8791 await app . client . removeListener ( events [ i ] , ( ) => { } ) ;
8892 } ;
93+ } ;
8994
9095 app . client = null ;
9196 } ;
@@ -132,7 +137,8 @@ async function bot(debug, lastMessageID = null) {
132137 } , 500 ) ;
133138
134139
135- }
140+ } ;
141+
136142 process . exitHandler = ( options , exitCode ) => exitHandler ( options , exitCode ) ;
137143
138144 // Kinda dumb how I had to shove it into the bot function but it's whatever.
0 commit comments