summaryrefslogtreecommitdiff
path: root/src/main/richpresence.ts
blob: 4ef8f42e36757d28ea8a844273496ee050004a49 (plain) (blame)
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
// Only for testing as of right now
const DiscordRPC = require('discord-rpc');

const ClientId = '447258715586822154';

DiscordRPC.register(ClientId);

const rpc = new DiscordRPC.Client({ transport: 'ipc' });
const startTimestamp = new Date();

async function setActivity() {
  if (!rpc)
    return false;

  rpc.setActivity({
    details: `booped times`,
    startTimestamp,
    largeImageKey: 'connect',
    largeImageText: 'Currently on map xy',
    // smallImageKey: 'snek_small',
    // smallImageText: 'i am my own pillows',
    partySize:2, //TODO get online players
    partyMax:999,
    partyId:"ae488379-351d-4a4f-ad32-2b9b01c91657",
    joinSecret:"MTI4NzM0OjFpMmhuZToxMjMxMjM="
  });
}

rpc.on('ready', () => {
  setActivity();

  // activity can only be set every 15 seconds
  setInterval(() => {
    setActivity();
  }, 15e3);
});

rpc.login(ClientId).catch(console.error);

rpc.subscribe("",console.log);

export function quit(){
  rpc.destroy();
  console.log("Shutting down Discord RPC integration");
}