-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (29 loc) · 999 Bytes
/
Copy pathindex.js
File metadata and controls
36 lines (29 loc) · 999 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
const RPC = require('discord-rpc');
const activeWin = require('active-win');
const clientId = 'DISCORD BOT APPLICATION ID HERE';
const rpc = new RPC.Client({ transport: 'ipc' });
rpc.on('ready', () => {
console.log('RPC connected');
setInterval(async () => {
let win;
try {
win = await activeWin();
} catch (err) {
console.error("Error getting active window:", err);
}
if (win && win.owner && win.owner.name) {
rpc.setActivity({
details: 'Active on Windows 11',
state: `Using: ${win.owner.name}`,
instance: false
});
} else {
rpc.setActivity({
details: 'Active on Windows 11',
state: 'Idle',
instance: false
});
}
}, 5000); // updates every 5 seconds for faster testing
});
rpc.login({ clientId }).catch(console.error);