├── LICENSE ├── README.md ├── images ├── protected pc run anyway.png ├── protected pc.png ├── rpc empty.png ├── rpc example.png ├── rpc full.png └── rpc icon.png ├── package.json └── src ├── index.css ├── index.html ├── index.js └── main.js /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # discord-rpc-with-buttons 2 | A discord RPC application that uses the new button feature of Discord's RPC API. 3 | 4 | ## 📌 Usage 📌 5 | 6 | [Youtube Tutorial](https://youtu.be/1T1jJdHvuBo) 7 | 8 | 1) Download the latest release from [here](https://github.com/hipvpitsme/discord-rpc-with-buttons/releases) 9 | 10 | 2) Unzip the zip and double click `discord-rpc-hipvpitsme-X.X.X Setup.exe` 11 | 12 | 3) An icon will appear on your desktop, double click to run it. This will open the applications GUI. Check the configuration guide for help with configuring. 13 | 14 | ## ⚙️ Configuration guide ⚙️ 15 | 16 | The code updates your status every 5 seconds, it will also write the current files to the config file to save your data when the application is started next, so if your status is taking longer to update, please refer to the troubleshooting guide. 17 | 18 | When you start the application, it will load default values from the config file. Push clear all to clear the values. 19 | 20 | ### Placeholders 21 | * State 22 | * The state of your client. 23 | * Client ID 24 | * The client ID of your Discord RPC application. If you change this you must restart the application. 25 | * Details 26 | * The string that shows under the application name in your RPC. This can be a max of 128 characters. 27 | * Large Image 28 | * The large image that will appear in your RPC. This should be the key for an asset in your application. 29 | * Large Text 30 | * The text that appears when you hover over the large image. This can be 128 characters max. 31 | * Small Image 32 | * The small image that will appear in your RPC. This should be the key for an asset in your application. 33 | * Small Text 34 | * The text that appears when you hover over the small image. This can be 128 characters max. 35 | * Button 1 and 2 Toggle 36 | * Determines if that button will show in your RPC. 37 | * Button 1 and 2 Label 38 | * The labels for either button 39 | * Button 1 and 2 URL 40 | * The URL that the user should be redirected to when they click the button, this must start with `https://` or `http://`. 41 | * Start 42 | * The start epoch time your client will use to determine your strat time. 43 | * End 44 | * The end time that your client will use to determine how much time is remaining. 45 | ## ⭐ Extras ⭐ 46 | 47 | ### Buttons 48 | Set Start To Current Time - This will set the start value to the current epoch time. 49 | Set End To Current Time Plus x Seconds - This will set the end value to the current epoch time plus how many seconds you enter, ex: 86400 seconds is a day so if you set the start time to the current time and the end time to plus that many seconds, your rpc will show you ending your game in 23 hours. 50 | 51 | ## ❗ Common issues ❗ 52 | If these don't help, join my [Discord](https://discord.gg/sjQXh8jRtK) for more help. 53 | 54 | ### If an error message pops up, read the error and do as it says or restart the app. 55 | 56 | * "Windows protected your PC" 57 | 58 | * To fix this, press "More Info" then "Run Anyway" 59 | * Buttons Cant Be Clicked 60 | * Restart the app 61 | * My buttons stopped working 62 | * Restart the app 63 | * My config erased itself 64 | * Yeah i don't know why it does this, it does it whevever your app has an error so just so stuff right lol 65 | 66 | ![RPC Windows Defender](https://hipvpitsme.github.io/discord-rpc-with-buttons/images/protected%20pc.png) 67 | 68 | * "On launch, the RPC doesn't start" 69 | 70 | * The RPC may not start immediately, please give it 2-5min to start. If it doesn't try changing some values. If it still doesn't work then join the [Discord](https://discord.gg/sjQXh8jRtK) for help. 71 | 72 | * "RPC not displaying" 73 | 74 | * Make sure you tried the "On launch, the RPC doesn't start" fix first. If that doesn't help then go to User Settings > Game Activity and make sure "Display currently running game as a status message" is toggled on or green. 75 | 76 | ## 🔧 Developement 🔧 77 | 78 | You will need [Git](https://git-scm.com/) and [NodeJS](https://nodejs.org/en/) 79 | 80 | ``` 81 | # clone the repo 82 | $ git clone https://github.com/hipvpitsme/discord-rpc-with-buttons.git 83 | 84 | # cd into the directory 85 | $ cd discord-rpc-with-buttons 86 | 87 | # install the packages 88 | $ npm install 89 | 90 | # start the application 91 | $ npm run start 92 | ``` 93 | 94 | ## ⚠️ License ⚠️ 95 | 96 | The license that I use allows anyone to use my code, change it in any way, and distribute it as long as my name is still on that code, so please do as you wish with it but do not claim it as your own :) 97 | -------------------------------------------------------------------------------- /images/protected pc run anyway.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hipvpitsme/discord-rpc-with-buttons/dfb0d5dc9774a37a60f63b0c4cf528a9f99d3739/images/protected pc run anyway.png -------------------------------------------------------------------------------- /images/protected pc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hipvpitsme/discord-rpc-with-buttons/dfb0d5dc9774a37a60f63b0c4cf528a9f99d3739/images/protected pc.png -------------------------------------------------------------------------------- /images/rpc empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hipvpitsme/discord-rpc-with-buttons/dfb0d5dc9774a37a60f63b0c4cf528a9f99d3739/images/rpc empty.png -------------------------------------------------------------------------------- /images/rpc example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hipvpitsme/discord-rpc-with-buttons/dfb0d5dc9774a37a60f63b0c4cf528a9f99d3739/images/rpc example.png -------------------------------------------------------------------------------- /images/rpc full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hipvpitsme/discord-rpc-with-buttons/dfb0d5dc9774a37a60f63b0c4cf528a9f99d3739/images/rpc full.png -------------------------------------------------------------------------------- /images/rpc icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hipvpitsme/discord-rpc-with-buttons/dfb0d5dc9774a37a60f63b0c4cf528a9f99d3739/images/rpc icon.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "discord-rpc-hipvpitsme", 3 | "productName": "discord-rpc-hipvpitsme", 4 | "version": "1.0.0", 5 | "description": "Discord Rich Presence App With Button Configuration", 6 | "main": "src/main.js", 7 | "scripts": { 8 | "start": "electron-forge start", 9 | "package": "electron-forge package", 10 | "make": "electron-forge make", 11 | "publish": "electron-forge publish", 12 | "lint": "echo \"No linting configured\"" 13 | }, 14 | "keywords": [], 15 | "author": { 16 | "name": "hipvpitsme", 17 | "email": "noturbusiness@nou.com" 18 | }, 19 | "license": "MIT", 20 | "config": { 21 | "forge": { 22 | "packagerConfig": {}, 23 | "makers": [ 24 | { 25 | "name": "@electron-forge/maker-squirrel", 26 | "config": { 27 | "name": "discord_rpc_hipvpitsme" 28 | } 29 | }, 30 | { 31 | "name": "@electron-forge/maker-zip", 32 | "platforms": [ 33 | "darwin" 34 | ] 35 | }, 36 | { 37 | "name": "@electron-forge/maker-deb", 38 | "config": {} 39 | }, 40 | { 41 | "name": "@electron-forge/maker-rpm", 42 | "config": {} 43 | } 44 | ] 45 | } 46 | }, 47 | "dependencies": { 48 | "discord-rpc": "^3.1.4", 49 | "electron-squirrel-startup": "^1.0.0", 50 | "jsonfile": "^6.1.0" 51 | }, 52 | "devDependencies": { 53 | "@electron-forge/cli": "^6.0.0-beta.54", 54 | "@electron-forge/maker-deb": "^6.0.0-beta.54", 55 | "@electron-forge/maker-rpm": "^6.0.0-beta.54", 56 | "@electron-forge/maker-squirrel": "^6.0.0-beta.54", 57 | "@electron-forge/maker-zip": "^6.0.0-beta.54", 58 | "electron": "11.2.1" 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 3 | margin: auto; 4 | max-width: 38rem; 5 | padding: 2rem; 6 | background-color: grey; 7 | } 8 | 9 | .button { 10 | border: black; 11 | color: aqua; 12 | background-color: coral; 13 | } 14 | 15 | .text { 16 | color: whitesmoke; 17 | font-size: small; 18 | } 19 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Discord Rich Presence 6 | 7 | 8 | 9 |

Click me for a tutorial on how to use!

10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 |

RPC Status: Off

26 |
27 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | var rpc = require("discord-rpc") 2 | const client = new rpc.Client({ transport: 'ipc' }) 3 | var killButton = document.getElementById('kill') 4 | var clearButton = document.getElementById('clear') 5 | var tutorialButton = document.getElementById('tutorial') 6 | var clientid = document.getElementById('clientid') 7 | var details = document.getElementById('details') 8 | var state = document.getElementById('state') 9 | var largeImage = document.getElementById('large_image') 10 | var largeText = document.getElementById('large_text') 11 | var buttonsEnabled = document.getElementById('buttons_enabled') 12 | var button1Enabled = document.getElementById('button1_enabled') 13 | var button2Enabled = document.getElementById('button2_enabled') 14 | var button1Label = document.getElementById('button1_label') 15 | var button1Url = document.getElementById('button1_url') 16 | var button2Label = document.getElementById('button2_label') 17 | var button2Url = document.getElementById('button2_url') 18 | const jsonFile = require('jsonfile') 19 | const fs = require('fs') 20 | const { ipcRenderer } = require('electron') 21 | tutorialButton.addEventListener('click', ()=>{ 22 | require('electron').shell.openExternal("https://github.com/hipvpitsme/discord-rpc-with-buttons") 23 | }) 24 | clearButton.addEventListener('click', ()=>{ 25 | buttonsEnabled.value = "" 26 | clientid.value = "" 27 | details.value = "" 28 | state.value = "" 29 | largeImage.value = "" 30 | largeText.value = "" 31 | button1Enabled.value = "" 32 | button1Label.value = "" 33 | button1Url.value = "" 34 | button2Enabled.value = "" 35 | button2Label.value = "" 36 | button2Url.value = "" 37 | }) 38 | killButton.addEventListener('click', ()=>{ 39 | ipcRenderer.sendSync('kill') 40 | }) 41 | function configExist() { 42 | if(fs.existsSync('config.json')) { 43 | return true 44 | } else { 45 | fs.createWriteStream('config.json') 46 | const obj = { 47 | clientid: "804405037953450014", 48 | buttons_enabled: "false", 49 | details: "Made by hipvpitsme", 50 | state: "test", 51 | large_image: "smile", 52 | large_text: "Made by hipvpitsme", 53 | buttons: { 54 | button1: { 55 | enabled: "false", 56 | label: "Made by hipvpitsme", 57 | url: "https://www.github.com/hipvpitsme" 58 | }, 59 | button2: { 60 | enabled: "false", 61 | label: "Made by hipvpitsme1", 62 | url: "https://www.github.com/hipvpitsme" 63 | } 64 | } 65 | } 66 | jsonFile.writeFileSync('config.json', obj) 67 | } 68 | } 69 | function writeBare() { 70 | const obj = { 71 | clientid: "804405037953450014", 72 | buttons_enabled: "false", 73 | details: "Made by hipvpitsme", 74 | state: "test", 75 | large_image: "smile", 76 | large_text: "Made by hipvpitsme", 77 | buttons: { 78 | button1: { 79 | enabled: "false", 80 | label: "Made by hipvpitsme", 81 | url: "https://www.github.com/hipvpitsme" 82 | }, 83 | button2: { 84 | enabled: "false", 85 | label: "Made by hipvpitsme1", 86 | url: "https://www.github.com/hipvpitsme" 87 | } 88 | } 89 | } 90 | jsonFile.writeFileSync('config.json', obj) 91 | } 92 | function writeConfig() { 93 | if(fs.existsSync('config.json')) { 94 | writeBare() 95 | } else { 96 | fs.createWriteStream('config.json') 97 | writeBare() 98 | } 99 | } 100 | function configValid() { 101 | var data 102 | try { 103 | data = jsonFile.readFileSync('config.json') 104 | } catch(err) { 105 | data = null 106 | } 107 | if(!data || !data.buttons || data.buttons === null || !data.buttons.button1 || data.buttons.button1 === null || !data.buttons.button2 || data.buttons.button2 === null || !data.details || data.details === "" || !data.state || data.state === "" || !data.large_image || data.large_image === "" || !data.large_text || data.large_text === "" || !data.clientid || !data.buttons_enabled || data.buttons_enabled === "") { 108 | writeConfig() 109 | } 110 | } 111 | function writeConfigVals(clientid, details, state, large_image, large_text, buttons_enabled, button1_enabled, button1_label, button1_url, button2_enabled, button2_label, button2_url) { 112 | let data = jsonFile.readFileSync('config.json') 113 | const obj = { 114 | clientid: clientid || data.clientid, 115 | buttons_enabled: buttons_enabled || data.buttons_enabled, 116 | details: details || data.details, 117 | state: state || data.state, 118 | large_image: large_image || data.large_image, 119 | large_text: large_text || data.large_text, 120 | buttons: { 121 | button1: { 122 | enabled: button1_enabled || data.buttons.button1.enabled, 123 | label: button1_label || data.buttons.button1.label, 124 | url: button1_url || data.buttons.button1.url 125 | }, 126 | button2: { 127 | enabled: button2_enabled || data.buttons.button2.enabled, 128 | label: button2_label || data.buttons.button2.label, 129 | url: button2_url || data.buttons.button2.url 130 | } 131 | } 132 | } 133 | jsonFile.writeFileSync('config.json', obj) 134 | } 135 | configExist() 136 | configValid() 137 | var initialData = jsonFile.readFileSync('config.json') 138 | buttonsEnabled.value = initialData.buttons_enabled 139 | clientid.value = initialData.clientid 140 | details.value = initialData.details 141 | state.value = initialData.state 142 | largeImage.value = initialData.large_image 143 | largeText.value = initialData.large_text 144 | button1Enabled.value = initialData.buttons.button1.enabled 145 | button1Label.value = initialData.buttons.button1.label 146 | button1Url.value = initialData.buttons.button1.url 147 | button2Enabled.value = initialData.buttons.button2.enabled 148 | button2Label.value = initialData.buttons.button2.label 149 | button2Url.value = initialData.buttons.button2.url 150 | var started = false 151 | client.on('ready', () => { 152 | setInterval(function() {setStatus()}, 1000) 153 | function setStatus() { 154 | configExist() 155 | configValid() 156 | let data = jsonFile.readFileSync('config.json') 157 | writeConfigVals(clientid.value, details.value, state.value, largeImage.value, largeText.value, buttonsEnabled.value, button1Enabled.value, button1Label.value, button1Url.value, button2Enabled.value, button2Label.value, button2Url.value) 158 | if(data.buttons_enabled.toLowerCase() === 'true') { 159 | let statusElement = document.getElementById('status') 160 | statusElement.innerHTML = '

RPC Status: On

' 161 | if(data.buttons.button1.enabled.toLowerCase() === 'true' && data.buttons.button2.enabled.toLowerCase() === 'true') { 162 | client.request('SET_ACTIVITY', { 163 | pid: process.pid, 164 | activity : { 165 | details : data.details, 166 | state : data.state, 167 | assets : { 168 | large_image : data.large_image, 169 | large_text : data.large_text 170 | }, 171 | buttons : [ 172 | {label : data.buttons.button1.label , url : data.buttons.button1.url}, 173 | {label : data.buttons.button2.label , url : data.buttons.button2.url} 174 | ] 175 | } 176 | }) 177 | } else if(data.buttons.button1.enabled.toLowerCase() === 'true') { 178 | let statusElement = document.getElementById('status') 179 | statusElement.innerHTML = '

RPC Status: On

' 180 | client.request('SET_ACTIVITY', { 181 | pid: process.pid, 182 | activity : { 183 | details : data.details, 184 | state : data.state, 185 | assets : { 186 | large_image : data.large_image, 187 | large_text : data.large_text 188 | }, 189 | buttons : [ 190 | {label : data.buttons.button1.label , url : data.buttons.button1.url}, 191 | ] 192 | } 193 | }) 194 | } else if(data.buttons.button2.enabled.toLowerCase() === 'true') { 195 | let statusElement = document.getElementById('status') 196 | statusElement.innerHTML = '

RPC Status: On

' 197 | client.request('SET_ACTIVITY', { 198 | pid: process.pid, 199 | activity : { 200 | details : data.details, 201 | state : data.state, 202 | assets : { 203 | large_image : data.large_image, 204 | large_text : data.large_text 205 | }, 206 | buttons : [ 207 | {label : data.buttons.button2.label , url : data.buttons.button2.url} 208 | ] 209 | } 210 | }) 211 | } 212 | } else if(data.buttons_enabled.toLowerCase() === 'false') { 213 | let statusElement = document.getElementById('status') 214 | statusElement.innerHTML = '

RPC Status: On

' 215 | client.request('SET_ACTIVITY', { 216 | pid: process.pid, 217 | activity : { 218 | details : data.details, 219 | state : data.state, 220 | assets : { 221 | large_image : data.large_image, 222 | large_text : data.large_text 223 | }, 224 | } 225 | }) 226 | } else { 227 | let statusElement = document.getElementById('status') 228 | statusElement.innerHTML = '

RPC Status: Error, Please Make Sure The Values That Can Only Be true or false Are Indeed Either true Or false

' 229 | } 230 | } 231 | }) 232 | if(!started) { 233 | try { 234 | started = true 235 | var currentFile = jsonFile.readFileSync('config.json') 236 | var currentClientId = currentFile.clientid 237 | let statusElement = document.getElementById('status') 238 | statusElement.innerHTML = '

RPC Status: On

' 239 | client.login({ clientId : currentClientId }).catch(err=>{ 240 | // console.log(err) 241 | statusElement.innerHTML = '

RPC Status: Error, please make sure your client id is correct and then restart the rpc

' 242 | }) 243 | } catch(err) { 244 | // console.log(err) 245 | started = true 246 | let statusElement = document.getElementById('status') 247 | statusElement.innerHTML = '

RPC Status: Error, Please Check If The Client ID is valid

' 248 | } 249 | } 250 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | const { app, BrowserWindow, ipcMain } = require('electron'); 2 | const path = require('path'); 3 | // Handle creating/removing shortcuts on Windows when installing/uninstalling. 4 | if (require('electron-squirrel-startup')) { // eslint-disable-line global-require 5 | app.quit(); 6 | } 7 | const createWindow = () => { 8 | // Create the browser window. 9 | const mainWindow = new BrowserWindow({ 10 | webPreferences: { 11 | nodeIntegration: true, 12 | devTools: false 13 | }, 14 | width: 300, 15 | height: 500, 16 | autoHideMenuBar: true, 17 | resizable: false, 18 | }); 19 | mainWindow.loadFile(path.join(__dirname, 'index.html')); 20 | // mainWindow.webContents.openDevTools(); 21 | }; 22 | app.on('ready', createWindow); 23 | //osx implementation 24 | app.on('window-all-closed', () => { 25 | if (process.platform !== 'darwin') { 26 | app.quit(); 27 | } 28 | }); 29 | app.on('activate', () => { 30 | if (BrowserWindow.getAllWindows().length === 0) { 31 | createWindow(); 32 | } 33 | }); 34 | ipcMain.on('kill', () => { 35 | app.quit() 36 | }) --------------------------------------------------------------------------------