Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Discord = require ( 'discord.js' ),
- Client = new Discord.Client ( ),
- Electron = require ( 'electron' ),
- App = Electron.app ,
- BrowserWindow = Electron.BrowserWindow ,
- ipc = Electron.ipcMain ;
- var Windows = Array ( ),
- Time = null ,
- User = { },
- Session = Array ( ),
- Settings = {
- width: 800 ,
- height: 600 ,
- frame: true ,
- resizable:
- false
- };
- var Library = { },
- UpdateEvents = Array ( ),
- Connection = Array ( );
- Library.add = { };
- Library.update = function ( ) {
- UpdateEvents.forEach ( ( item, index ) => {
- item ( );
- } );
- };
- Library.add.updateEvent = function ( e ) {
- if ( typeof e !== 'function' ) {
- console.log ( Time +'Expected function at Library.add.updateEvent ( e )' );
- return false;
- }
- UpdateEvents.push ( e );
- return true;
- };
- Library.add.updateEvent ( ( ) => {
- var d = new Date(),
- h = (d.getHours()<10?'0':'') + d.getHours(),
- m = (d.getMinutes()<10?'0':'') + d.getMinutes(),
- s = (d.getSeconds()<10?'0':'') + d.getSeconds();
- Time = '[' + h + ':' + m + ':' + s + '] ';
- } );
- var upd = setInterval ( Library.update, 200 );
- App.on ( 'ready', ( ) => {
- Windows.push ( new BrowserWindow ( Settings ) );
- Windows [ Windows.length - 1 ].setMenu ( null );
- Windows [ Windows.length - 1 ].loadURL ( 'file://' + __dirname + '/html/login.html' );
- Windows [ Windows.length - 1 ].show ( );
- } );
- ipc.on ( 'login-attempt', ( event, args ) => {
- console.log ( Time + 'Login | New sign in attempt triggered!' );
- if ( typeof args !== 'object' || args.token == undefined ) {
- console.log ( Time + 'Login | Invalid sign in attempt!' );
- event.sender.send ( 'login-attempt-error', 'Invalid request!' );
- return false;
- }
- Client.login ( args.token );
- } );
- Client.on ( 'ready', ( ) => {
- Client.channels.get ( 'id', '280984906228563969' ).sendMessage ( 'Hello World!' );
- } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement