-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
57 lines (49 loc) · 1.59 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const { app, BrowserWindow } = require('electron');
const path = require('path');
// Var stuff
const discordJS = require("discord.js");
const client = new discordJS.Client();
const utilFunctions = require("./src/util/util-functions.js");
const utilClasses = require("./src/util/util-classes.js");
utilClasses.create(client);
var token = "";
// Export stuff
exports.getDiscordJS = () => { return discordJS; };
exports.getDCJSClient = () => { return client; }
exports.setToken = (newToken) => { token = utilFunctions.encrypt(utilFunctions.getSalt(), newToken); }
exports.login = () => {
client.login(utilFunctions.decrypt(utilFunctions.getSalt(), token))
.catch((e) => {
console.error("O_o Client couldn't login. Gonna suicide", e);
app.exit();
});
}
exports.getUtilClasses = () => { return utilClasses; };
app.on('ready', () => {
// Create browser window
const window = new BrowserWindow({
width: 1000,
height: 900,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true
}
});
// Remove that stupid menu bar
window.setMenu(null);
// Load BG Scripts first
require("./src/background/dc_listeners");
// Load app
window.loadFile(path.join(__dirname, 'src/app/app.html'));
// Open DEVTOOLS
window.openDevTools();
});
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') { // darwin is mac for some reason
app.quit();
}
});