-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatman-rpc.js
More file actions
38 lines (32 loc) · 858 Bytes
/
batman-rpc.js
File metadata and controls
38 lines (32 loc) · 858 Bytes
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
const RPC = require('discord-rpc');
const { exec } = require('child_process');
const clientId = '1395414403599302770';
RPC.register(clientId);
const rpc = new RPC.Client({ transport: 'ipc' });
function setActivity() {
if (!rpc) return;
rpc.setActivity({
details: 'Playing Batman: Arkham Knight',
startTimestamp: Date.now(),
largeImageKey: 'batman',
largeImageText: 'Batman: Arkham Knight',
instance: false,
});
}
function checkIfBatmanRunning() {
exec('tasklist', (err, stdout, stderr) => {
if (err) return;
const isRunning = stdout.toLowerCase().includes('batmanak.exe');
if (!isRunning) {
process.exit();
}
});
}
rpc.on('ready', () => {
setActivity();
setInterval(() => {
setActivity();
}, 15e3);
});
rpc.login({ clientId }).catch(console.error);
setInterval(checkIfBatmanRunning, 2000);