-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpreload.js
43 lines (32 loc) · 995 Bytes
/
preload.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
const RPC = require('discord-rpc')
const rpc = new RPC.Client({ transport: 'ipc' })
fullClients = {
vrc: 'Virtual Radar Client',
euroscope: 'EuroScope',
vstars: 'vSTARS',
veram: 'vERAM',
ivac: 'IvAc'
}
fullNetworks = {
vatsim: 'VATSIM',
ivao: 'IVAO'
}
const start = Date.now()
window.stopRpc = async () => { await rpc.clearActivity() }
window.setRpc = async (position, client, network) => {
await rpc.setActivity({
details: position,
state: (client === 'vrc' ? 'VRC' : fullClients[client])
+ (network === 'other' ? '' : ` on ${fullNetworks[network]}`),
startTimestamp: start,
largeImageKey: client,
largeImageText: fullClients[client],
smallImageKey: network === 'other' ? undefined : network,
smallImageText: fullNetworks[network],
instance: false
})
}
rpc.on('ready', async () => {
console.log('Authed for user', rpc.user.username)
})
rpc.login({ clientId: '832386811383906320' })