-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
56 lines (51 loc) · 1.48 KB
/
index.js
File metadata and controls
56 lines (51 loc) · 1.48 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
const data = Date.now()
const clientId = '632286895665315855';
const RPC = require('discord-rpc');
const activeWin = require('active-win');
RPC.register(clientId);
const client = new RPC.Client({
transport: 'ipc'
});
async function updatePresence() {
let window = activeWin.sync();
try {
window = {
name: window.owner.name,
title: window.title
}
let anime = {
name: window.title.match(/Аниме (.*) смотреть онлайн/) ? window.title.match(/Аниме (.*) смотреть онлайн/)[1] : null,
status: 'Просматривается, серия: [?/?]' //TODO: вывод серии / по возможности thumbnail
}
if(anime.name === null) {
anime = {
name: 'Currently in '+ window.name,
status: 'Не просматривается, открыто другое окно'
}
}
updateRP(anime);
} catch (e) {
console.log(e);
}
}
function updateRP(anime) {
client.setActivity({
details: anime.name,
state: anime.status,
largeImageKey: '-1',
largeImageText: 'YummyAnime', //TODO: вывод серии / по возможности thumbnail
startTimestamp: data,
instance: false
}).catch(err => {
console.log(err);
});
}
client.on('ready', () => {
console.log("Connected!");
setInterval(() => {
updatePresence();
}, 10000);
});
client.login({
clientId
}).catch(console.error);