Advertisement
TechnicCoder

app.js

Feb 18th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Discord       =     require                 ( 'discord.js' ),
  2.     Client        = new Discord.Client          (              ),
  3.    
  4.     Electron      =     require                 (  'electron'  ),
  5.     App           =     Electron.app                            ,
  6.     BrowserWindow =     Electron.BrowserWindow                  ,
  7.     ipc           =     Electron.ipcMain                        ;
  8.  
  9.  
  10. var Windows       =     Array                   (              ),
  11.     Time          =     null                                    ,
  12.     User          =                             {              },
  13.     Session       =     Array                   (              ),
  14.     Settings      =                             {
  15.                                                   width: 800  ,
  16.                                                   height: 600 ,
  17.                                                   frame: true ,
  18.                                                   resizable:
  19.                                                         false
  20.                                                                };
  21.  
  22. var Library      =       {  },
  23.     UpdateEvents = Array (  ),
  24.     Connection   = Array (  );
  25.  
  26. Library.add      =       {  };
  27.  
  28. Library.update = function (  ) {
  29.   UpdateEvents.forEach ( ( item, index ) => {
  30.     item (  );
  31.   } );
  32. };
  33.  
  34. Library.add.updateEvent = function ( e ) {
  35.   if ( typeof e !== 'function' ) {
  36.     console.log ( Time +'Expected function at Library.add.updateEvent ( e )' );
  37.     return false;
  38.   }
  39.  
  40.   UpdateEvents.push ( e );
  41.   return true;
  42. };
  43.  
  44.  
  45.  
  46.  
  47.  
  48. Library.add.updateEvent ( (  ) => {
  49.   var d = new Date(),
  50.       h = (d.getHours()<10?'0':'') + d.getHours(),
  51.       m = (d.getMinutes()<10?'0':'') + d.getMinutes(),
  52.       s = (d.getSeconds()<10?'0':'') + d.getSeconds();
  53.   Time = '[' + h + ':' + m + ':' + s + '] ';
  54. } );
  55.  
  56.  
  57.  
  58. var upd = setInterval ( Library.update, 200 );
  59.  
  60.  
  61.  
  62.  
  63. App.on ( 'ready', (  ) => {
  64.   Windows.push ( new BrowserWindow ( Settings ) );
  65.   Windows [ Windows.length - 1 ].setMenu ( null                                       );
  66.   Windows [ Windows.length - 1 ].loadURL ( 'file://' + __dirname + '/html/login.html' );
  67.   Windows [ Windows.length - 1 ].show    (                                            );
  68. } );
  69.  
  70. ipc.on ( 'login-attempt', ( event, args ) => {
  71.   console.log ( Time + 'Login | New sign in attempt triggered!' );
  72.  
  73.   if ( typeof args !== 'object' || args.token == undefined ) {
  74.     console.log ( Time + 'Login | Invalid sign in attempt!' );
  75.     event.sender.send ( 'login-attempt-error', 'Invalid request!' );
  76.     return false;
  77.   }
  78.  
  79.   Client.login ( args.token );
  80.  
  81. } );
  82.  
  83. Client.on ( 'ready', (  ) => {
  84.   Client.channels.get ( 'id', '280984906228563969' ).sendMessage ( 'Hello World!' );
  85. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement