diff options
author | Minteck <contact@minteck.org> | 2022-05-18 18:50:12 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-05-18 18:50:12 +0200 |
commit | 0bd45cb2cae3af05adaad3f38d129bb67c3e0ec0 (patch) | |
tree | 97a7e15187fe7fcb5b8775e03a62f62ac8fc5c61 /kartik/discord | |
parent | d4805039b8ea7b30f5e78cf53caf8fd3f267256a (diff) | |
download | arcade-trunk.tar.gz arcade-trunk.tar.bz2 arcade-trunk.zip |
Diffstat (limited to 'kartik/discord')
-rwxr-xr-x | kartik/discord/client.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/kartik/discord/client.js b/kartik/discord/client.js new file mode 100755 index 0000000..d849ed3 --- /dev/null +++ b/kartik/discord/client.js @@ -0,0 +1,40 @@ +const DiscordRPC = require('discord-rpc'); + +// Set this to your Client ID. +const clientId = '821064368535633920'; + +// Only needed if you want to use spectate, join, or ask to join +DiscordRPC.register(clientId); + +const rpc = new DiscordRPC.Client({ transport: 'ipc' }); +const startTimestamp = new Date(); + +async function setActivity() { + if (!rpc) { + return; + } + + //const boops = await mainWindow.webContents.executeJavaScript('window.boops'); + + // You'll need to have snek_large and snek_small assets uploaded to + // https://discord.com/developers/applications/<application_id>/rich-presence/assets + rpc.setActivity({ + details: win.ddetails, + state: win.dstate, + startTimestamp, + largeImageKey: 'kartik', + largeImageText: 'Kartik, ' + lang.game.credits.by + ' Minteck', + smallImageKey: dimg, + smallImageText: dchan, + instance: false, + }); +} + +rpc.on('ready', () => { + // activity can only be set every 15 seconds + setInterval(() => { + setActivity(); + }, 15e3); +}); + +rpc.login({ clientId }).catch(console.error);
\ No newline at end of file |