@@ -46,69 +46,7 @@ const app = {
4646 }
4747 } ,
4848
49- defaults : {
50- // -- HEY!!!
51- // -- WARNING :: THIS IS DANGEROUS | ONLY ACCESS DATA FROM MESSAGE. DO NOT ACCESS DATA FROM OTHER VARIABLES.
52- // -- It poses a major security risk and TMC Software is not responsible for that.
53-
54- join : {
55- msg : "Hello and welcome %user% to the %server%!" ,
56- types : [
57- // SERVER INFO
58- { "%server%" : { "desc" : "Server Name (Cool Place)" , "replaceWith" : "guild|name" } } ,
59- { "%serverID%" : { "desc" : "Server ID (99999999999999999)" , "replaceWith" : "guild|id" } } ,
60-
61- // USER INFO
62- { "%username%" : { "desc" : "Username (John Doe)" , "replaceWith" : "user|username" } } ,
63- { "%userID%" : { "desc" : "User ID (99999999999999999)" , "replaceWith" : "user|id" } } ,
64- { "%userdisc%" : { "desc" : "User Discriminator (#0001)" , "replaceWith" : "user|discriminator" } } ,
65- { "%usertag%" : { "desc" : "User Tag (John Doe#0001)" , "replaceWith" : "user|tag" } } ,
66- { "%user%" : { "desc" : "User Mention (@John Doe#0001)" , "replaceWith" : "user|toString()" } } ,
67-
68- // INVITE INFO
69- { "%invitecode%" : { "desc" : "Invite Code (HdKeWtV)" , "replaceWith" : "Unknown" } } ,
70- { "%inviteuses%" : { "desc" : "Invite Uses (34)" , "replaceWith" : "" } } ,
71- { "%invitername%" : { "desc" : "Inviter Username (Jane Doe)" , "replaceWith" : "" } } ,
72- { "%inviterID%" : { "desc" : "Inviter ID (11111111111111111)" , "replaceWith" : "" } } ,
73- { "%inviterdisc%" : { "desc" : "Inviter Discriminator (#0002)" , "replaceWith" : "" } } ,
74- { "%invitertag%" : { "desc" : "Inviter Tag (Jane Doe#0001)" , "replaceWith" : "" } } ,
75- { "%inviter%" : { "desc" : "Inviter Mention (@Jane Doe#0002)" , "replaceWith" : "" } }
76- ]
77- } ,
78- leave : {
79- msg : "Aw... %user% just left the server..." ,
80- types : [
81- // SERVER INFO
82- { "%server%" : { "desc" : "Server Name (Cool Place)" , "replaceWith" : "guild|name" } } ,
83- { "%serverID%" : { "desc" : "Server ID (99999999999999999)" , "replaceWith" : "guild|id" } } ,
84-
85- // USER INFO
86- { "%username%" : { "desc" : "Username (John Doe)" , "replaceWith" : "user|username" } } ,
87- { "%userID%" : { "desc" : "User ID (99999999999999999)" , "replaceWith" : "user|id" } } ,
88- { "%userdisc%" : { "desc" : "User Discriminator (#0001)" , "replaceWith" : "user|discriminator" } } ,
89- { "%usertag%" : { "desc" : "User Tag (John Doe#0001)" , "replaceWith" : "user|tag" } } ,
90- { "%user%" : { "desc" : "User Mention (@John Doe#0001)" , "replaceWith" : "user|toString()" } }
91- ]
92- }
93- } ,
94-
9549 functions : {
96- getTypes : { // these functions were retardly dumb and overly complicated for no reason.
97- desc : ( val ) => {
98- var temp = [ ] ,
99- defaults = app . defaults ;
100- for ( var i = 0 ; i < Object . keys ( defaults [ val ] [ "types" ] ) . length ; i ++ ) temp . push ( Object . keys ( defaults [ val ] [ "types" ] [ i ] ) + " = " + defaults [ val ] [ "types" ] [ i ] [ Object . keys ( defaults [ val ] [ "types" ] [ i ] ) ] [ "desc" ] ) ;
101- return temp ;
102- } ,
103-
104- replaceWith : ( val ) => {
105- var temp = { } ,
106- defaults = app . defaults ;
107- for ( var i = 0 ; i < Object . keys ( defaults [ val ] [ "types" ] ) . length ; i ++ ) temp [ [ Object . keys ( defaults [ val ] [ "types" ] [ i ] ) [ 0 ] ] ] = defaults [ val ] [ "types" ] [ i ] [ Object . keys ( defaults [ val ] [ "types" ] [ i ] ) [ 0 ] ] [ "replaceWith" ] ;
108- return temp ;
109- }
110- } ,
111-
11250 sleep : function ( ms ) {
11351 return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
11452 } ,
@@ -296,37 +234,14 @@ const app = {
296234 delete options [ "author" ] ;
297235 } ;
298236 if ( ! options . embeds [ 0 ] [ "footer" ] ) options . embeds [ 0 ] [ "footer" ] = { text : app . config . system . footerText } ; // Install branding.exe
299- if ( options . embeds [ 0 ] [ "thumbnail" ] != null ) {
300- var user = options . embeds [ 0 ] [ "thumbnail" ] ;
301- if ( user [ "url" ] == null )
302- options . embeds [ 0 ] [ "thumbnail" ] = { url : user . displayAvatarURL ( { format : 'png' , dynamic : true , size : 1024 } ) } ;
303-
304- }
305237 } ;
306238
307- var currTime = new Date ( ) . getTime ( ) ;
308-
309239 if ( action == 0 ) {
310- if ( doReply && message . channel ) options [ "reply" ] = { messageReference : message . id } ;
311-
312- if ( message . channel )
313- message . channel . send ( options ) . then ( msg => {
314- if ( message . createdTimestamp )
315- app . logger . debug ( "DISCORD" , `[MESSAGE] Got message in ${ ( currTime - message . createdTimestamp ) / 1000 } ms. | Responded in ${ ( currTime - msg . createdTimestamp ) / 1000 } ms.` ) ;
316- if ( callback != null ) callback ( msg ) ;
317- } ) . catch ( err => { app . logger . warn ( "DISCORD" , `[MESSAGE] Message failed to send! Error: ${ err . message } ` ) } ) ;
318- else
319- message . send ( options ) . then ( msg => { if ( callback != null ) callback ( msg ) ; } ) . catch ( err => { app . logger . warn ( "DISCORD" , `[MESSAGE] Message failed to send! Error: ${ err . message } ` ) } ) ;
240+ if ( doReply ) options [ "reply" ] = { messageReference : message . id } ;
241+ message . channel . send ( options ) . then ( msg => { if ( callback != null ) callback ( msg ) ; } ) ;
320242 } else if ( action == 1 ) {
321- if ( ! message . channel ) return ; // Hate to break it, but you can't edit a channel as a message. 💀 (imagine that)
322- if ( message . edit ) message . edit ( options ) . then ( msg => {
323- if ( message . editedTimestamp ) app . logger . debug ( "DISCORD" , `[MESSAGE] Edited message in ${ ( currTime - msg . editedTimestamp ) / 1000 } ms.` ) ;
324- if ( callback != null ) callback ( msg ) ;
325- } ) . catch ( err => { app . logger . warn ( "DISCORD" , `[MESSAGE] Message failed to edit! Error: ${ err . message } ` ) } ) ;
326- else if ( message . update ) message . update ( options ) . then ( msg => {
327- if ( message . editedTimestamp ) app . logger . debug ( "DISCORD" , `[MESSAGE] Edited message in ${ ( currTime - msg . editedTimestamp ) / 1000 } ms.` ) ;
328- if ( callback != null ) callback ( msg ) ;
329- } ) . catch ( err => { app . logger . warn ( "DISCORD" , `[MESSAGE] Message failed to update! Error: ${ err . message } ` ) } ) ;
243+ if ( message . edit ) message . edit ( options ) . then ( msg => { if ( callback != null ) callback ( msg ) ; } ) ;
244+ else if ( message . update ) message . update ( options ) . then ( msg => { if ( callback != null ) callback ( msg ) ; } ) ;
330245 } ;
331246 } ,
332247
@@ -396,7 +311,7 @@ const app = {
396311 } ;
397312
398313 app . functions . msgHandler ( message , data , 0 , true ) ;
399- app . logger . error ( "SYS" , "[ERRHANDLER] " + ( err . stack || err . message || err ) ) ;
314+ console . log ( err ) ;
400315 return ;
401316 } ,
402317
@@ -419,16 +334,6 @@ const app = {
419334 } ,
420335 getID : function ( string ) { return string . replace ( / [ < # @ & ! > ] / g, '' ) ; } ,
421336 doesArrayStartsWith : function ( string , array ) { return array . findIndex ( ( item ) => { return item . startsWith ( string ) ; } , string ) != - 1 ; } ,
422- arrayDifference : function ( arr1 , arr2 ) {
423- var a = [ ] ,
424- diff = [ ] ;
425- for ( var i = 0 ; i < arr1 . length ; i ++ ) { a [ arr1 [ i ] ] = true ; } ;
426- for ( var i = 0 ; i < arr2 . length ; i ++ ) {
427- if ( a [ arr2 [ i ] ] ) { delete a [ arr2 [ i ] ] ; } else { a [ arr2 [ i ] ] = true ; } ;
428- } ;
429- for ( var k in a ) { diff . push ( k ) ; } ;
430- return diff ;
431- } ,
432337
433338 clearCache : function ( module ) {
434339 if ( module == null )
@@ -437,7 +342,7 @@ const app = {
437342 delete require . cache [ module ] ;
438343 } ,
439344 getFiles : async function ( dir , filter = [ ] ) {
440- if ( filter . length > 2 ) return "filter too powerfuuuuul [startsWith, endsWith] only please, or no filter ." ;
345+ if ( filter . length > 2 ) return "Fliter too powerfuuuuul [startsWith, endsWith] only please, or no fliter ." ;
441346
442347 const { resolve } = app . modules [ "path" ] ;
443348 const { readdir } = app . modules [ "fs" ] . promises ;
0 commit comments