-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
87 lines (61 loc) · 2.33 KB
/
index.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
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
77
78
79
80
81
82
83
84
85
86
87
const RPC = require('discord-rpc')
global.data = require('./state.json');
const clientId = `${data.appinfo.clientID}`;
const fs = require('fs')
/////////////////////////Update Cache////////////////////////
fs.watchFile(require.resolve('./state.json'), function () {
console.log("Information changed, reloading...\n");
delete require.cache[require.resolve('./state.json')]
global.data = require('./state.json');
setTimeout(() => {
if(data.modeplay.where === 'y'){
setActivityingame();
}else{
setActivityinmenu();
}
}, 100);
});
////////////////////////// end ////////////////////////////
// Only needed if you want to use spectate, join, or ask to join
RPC.register(clientId);
const rpc = new RPC.Client({ transport: 'ipc' });
const startTimestamp = new Date();
console.log('Log in World of Warcraft ... \n\n ')
/////////////////////function////////////////////
async function setActivityingame() {
rpc.setActivity({
details: `${data.info.details}`,
state: `${data.info.state}`,
startTimestamp,
largeImageKey: `${data.zone.largeImageKey}`,
largeImageText: `${data.info.largeImageText}`,
smallImageKey: `${data.class.smallImageKey}`,
smallImageText: `${data.info.smallImageText}`,
instance: false,
});
console.log(`Activity update / in game \n`)
console.log(`_________________________________________ \n| Name:${data.info.details} \n| Class And Talent: ${data.info.state} \n| Class:${data.info.largeImageText} \n| Team:${data.info.smallImageText} \n_________________________________________ `)
}
async function setActivityinmenu() {
rpc.setActivity({
details: `Character list`,
state: `${data.modeplay.waudoing}`,
startTimestamp,
largeImageKey: `main`,
instance: false,
});
console.log(`Activity update / in menu `)
console.log(`______________________________ \n| Details: Character list | \n______________________________ `)
}
///////////////////function end////////////////////
//console.log(`${data.modeplay.where} `)
rpc.on('ready', () => {
// if "where"= x : Player in Menu
// if "where"= y : Player in Game
if(data.modeplay.where === 'y'){
setActivityingame();
}else{
setActivityinmenu();
}
});
rpc.login({ clientId }).catch(console.error);