diff --git a/.gitignore b/.gitignore index ceaea36..3f66c2b 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,5 @@ dist .yarn/install-state.gz .pnp.* +# This is just for testing but im too lazy to remove it lol +helpme.json \ No newline at end of file diff --git a/README.md b/README.md index bbccf59..cd55eb6 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,8 @@ SteamRPC pulls your game and presence from Steam and puts it onto discord. ## Table of Contents - [Setup](#setup) - [Downloading the repository](#downloading-the-repository) - - [Discord Setup](#discord-setup) - [Steam Setup](#steam-setup) - [Running it](#running-it) -- [Customization](#customization) - [Notes](#notes) ## Setup @@ -22,19 +20,11 @@ cd SteamRPC In order for SteamRPC to run, you need to give it 2 environment variables.
Example: ```bash -CLIENT_ID=1234567890 STEAM_ID=12345678 node index.js +STEAM_ID=12345678 node index.js ``` Below you can find documentation for how to get the Discord Client ID and the Steam ID. -### Discord Setup - -1. Navigate to the [Discord Developer Portal](https://discord.com/developers/) and sign in. -2. In the top right, hit the button that says "New Application". You can name this application whatever you want, but I recommend SteamRPC. -3. Copy the application ID. - -And thats pretty much it! Now just fill the CLIENT_ID environment variable in with your newly obtained Application ID - ### Steam Setup Getting your Steam ID is a much simpler process. @@ -47,26 +37,10 @@ Now replace the STEAM_ID environment variable with the SteamID you just got. Although this isn't nessacarily the most sophisticated method for getting your steam ID, its the one I find the easiest. -## Customization - -### By default, you may notice that the games have no images -This is sadly a limitation of Discord, and I currently do not believe there is an easy method around it. For now, I have developed an easy alternative. - -1. Go back to the [Discord Developer Portal](https://discord.com/developers) and navigate to the page for your newly made application. -2. On the left, click on "Rich Presence" and go to "Art Assets" -3. Click `Add Image(s)` and upload the icon you want for your game -4. Name it the name of your game **Without Spaces or caps** - -* Please note that images do need to be 256x256, but you can easily find some application to upscale it if you so desire. - -And your done! -Here is an example of my current setup:
-![A photo of my setup, with Gunfire Reborn and Risk of rain 2. The Gunfire Reborn is simply named "gunfirereborn" and Risk of Rain 2 is named "riskofrain2"](docs/images/setupExample.png) - ### Running it Lastly, all you need to do, is open a terminal and run ``` -CLIENT_ID=[your discord client ID] STEAM_ID=[your steam id] node index.js +STEAM_ID=[your steam id] node index.js ``` There are also option environment variables: diff --git a/index.js b/index.js index 0aab824..759ae65 100644 --- a/index.js +++ b/index.js @@ -2,13 +2,16 @@ const fs = require('fs') var updateTime = (process.env.UPDATE_TIME || 30) -const clientId = process.env.CLIENT_ID +var clientId = "1176317740512985119" + const steamID = process.env.STEAM_ID -if (clientId == undefined) { - console.error("No client ID was defined! Please check the documentation for how to add one.") - return -} +const thumborURL = "https://thumbor-production-0e82.up.railway.app/unsafe/fit-in/512x512/filters:fill(transparent)/" + +// if (clientId == undefined) { +// console.error("No client ID was defined! Please check the documentation for how to add one.") +// return +// } if (steamID == undefined) { console.error("No Steam ID was defined! Please check the documentation for how to add one.") @@ -33,7 +36,10 @@ function update() { .then((html) => { var json = { "name": "nothing", - "presence": "" + "presence": "", + "img": "", + "pfp": html.substring(html.indexOf('")) } + if (html.includes("persona")) { + var blah = html.substring(html.indexOf("persona"), html.length) + json.username = blah.substring(blah.indexOf(">") + 1, blah.indexOf("")) + } + + if (html.includes("game_logo")) { + var blah = html.substring(html.indexOf('game_logo" src="') + 'game_logo" src="'.length + 8, html.indexOf("capsule")) + json.img = thumborURL + blah + "logo.png" + } + if (prevGame != json.name) { prevGame = json.name startTime = Date.now() } - + client.setActivity({ details: `Playing ${json.name}`, state: json.presence, startTimestamp: startTime, - largeImageKey: json.name.split(" ").join("").toLowerCase(), - largeImageText: json.name - }); - + largeImageText: json.name, + largeImageKey: json.img, + smallImageText: json.username, + smallImageKey: json.pfp, + }); + if (json.gameName == "nothing") { updateTime = (process.env.UPDATE_TIME || 30) * 2.5 } else { @@ -78,9 +96,9 @@ client.on('ready', () => { }); process.on('uncaughtException', (err, origin) => { - fs.writeSync( - process.stderr.fd, - `Caught exception: ${err}\n` + - `Exception origin: ${origin}`, - ) + fs.writeSync( + process.stderr.fd, + `Caught exception: ${err}\n` + + `Exception origin: ${origin}`, + ) }) diff --git a/package-lock.json b/package-lock.json index 6d692fa..f46ea03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,13 @@ { - "name": "discordUpdater", + "name": "steamrpc", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { + "name": "steamrpc", + "version": "1.0.0", + "license": "GPL-3.0-or-later", "dependencies": { "discord-rpc": "^4.0.1" } diff --git a/package.json b/package.json index 45d8c4a..737824b 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,6 @@ "description": "SteamRPC pulls your game and presence from Steam and puts it onto discord.", "version": "1.0.0", "main": "index.js", - "devDependencies": {}, "scripts": { "test": "node index.js" },