-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
78 lines (61 loc) · 1.73 KB
/
Copy pathmain.js
File metadata and controls
78 lines (61 loc) · 1.73 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const { app, BrowserWindow } = require('electron')
const os = require('os');
const fs = require('fs');
const path = require('path');
const DiscordRPC = require('discord-rpc');
const { type } = require('process');
const createWindow = () => {
const win = new BrowserWindow({
width: 350,
height: 200,
autoHideMenuBar: true,
resizable: false,
webPreferences: {
contextIsolation: false,
nodeIntegration: true,
webSecurity: false
},
})
win.loadFile(path.join(__dirname, `/src/start.html`))
}
app.whenReady().then(() => {
createWindow()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
})
// get valorant-stream-overlay directory from local appdata directory
const folderPath = path.join(os.homedir(), 'AppData', 'Local', 'valorant-stream-overlay');
// create the valorant-stream-overlay directory if it doesnt exist
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
const startTimestamp = new Date();
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
const clientId = '1142956480660774922';
async function setActivity() {
if (fs.readFileSync(folderPath + "\\options\\discord_rpc", "utf-8") == "false")
return;
rpc.setActivity({
details: `v0.0.4`,
startTimestamp,
largeImageKey: 'logo',
largeImageText: 'Valorant Stream Overlay',
instance: false,
buttons: [
{ label: "Repository", url: "https://github.com/Vaneeyo/Valorant-Stream-Overlay"}
]
});
}
rpc.on('ready', () => {
setActivity();
setInterval(() => {
setActivity();
}, 15e3);
});
rpc.login({ clientId }).catch(console.error);