Automatic Images!
This commit is contained in:
parent
5caf86fd58
commit
8b6aaaa44b
5 changed files with 43 additions and 46 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -130,3 +130,5 @@ dist
|
||||||
.yarn/install-state.gz
|
.yarn/install-state.gz
|
||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
|
# This is just for testing but im too lazy to remove it lol
|
||||||
|
helpme.json
|
30
README.md
30
README.md
|
@ -5,10 +5,8 @@ SteamRPC pulls your game and presence from Steam and puts it onto discord.
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
- [Setup](#setup)
|
- [Setup](#setup)
|
||||||
- [Downloading the repository](#downloading-the-repository)
|
- [Downloading the repository](#downloading-the-repository)
|
||||||
- [Discord Setup](#discord-setup)
|
|
||||||
- [Steam Setup](#steam-setup)
|
- [Steam Setup](#steam-setup)
|
||||||
- [Running it](#running-it)
|
- [Running it](#running-it)
|
||||||
- [Customization](#customization)
|
|
||||||
- [Notes](#notes)
|
- [Notes](#notes)
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
@ -22,19 +20,11 @@ cd SteamRPC
|
||||||
|
|
||||||
In order for SteamRPC to run, you need to give it 2 environment variables. <br> Example:
|
In order for SteamRPC to run, you need to give it 2 environment variables. <br> Example:
|
||||||
```bash
|
```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.
|
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
|
### Steam Setup
|
||||||
|
|
||||||
Getting your Steam ID is a much simpler process.
|
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.
|
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: <br>
|
|
||||||
![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
|
### Running it
|
||||||
Lastly, all you need to do, is open a terminal and run
|
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:
|
There are also option environment variables:
|
||||||
|
|
34
index.js
34
index.js
|
@ -2,13 +2,16 @@ const fs = require('fs')
|
||||||
|
|
||||||
var updateTime = (process.env.UPDATE_TIME || 30)
|
var updateTime = (process.env.UPDATE_TIME || 30)
|
||||||
|
|
||||||
const clientId = process.env.CLIENT_ID
|
var clientId = "1176317740512985119"
|
||||||
|
|
||||||
const steamID = process.env.STEAM_ID
|
const steamID = process.env.STEAM_ID
|
||||||
|
|
||||||
if (clientId == undefined) {
|
const thumborURL = "https://thumbor-production-0e82.up.railway.app/unsafe/fit-in/512x512/filters:fill(transparent)/"
|
||||||
console.error("No client ID was defined! Please check the documentation for how to add one.")
|
|
||||||
return
|
// if (clientId == undefined) {
|
||||||
}
|
// console.error("No client ID was defined! Please check the documentation for how to add one.")
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
if (steamID == undefined) {
|
if (steamID == undefined) {
|
||||||
console.error("No Steam ID was defined! Please check the documentation for how to add one.")
|
console.error("No Steam ID was defined! Please check the documentation for how to add one.")
|
||||||
|
@ -33,7 +36,10 @@ function update() {
|
||||||
.then((html) => {
|
.then((html) => {
|
||||||
var json = {
|
var json = {
|
||||||
"name": "nothing",
|
"name": "nothing",
|
||||||
"presence": ""
|
"presence": "",
|
||||||
|
"img": "",
|
||||||
|
"pfp": html.substring(html.indexOf('<img src="https://avatars') + 10, html.indexOf("medium")) + "full.jpg",
|
||||||
|
"username": ""
|
||||||
}
|
}
|
||||||
|
|
||||||
if (html.includes("game_name")) {
|
if (html.includes("game_name")) {
|
||||||
|
@ -49,6 +55,16 @@ function update() {
|
||||||
json["presence"] = blah.substring(0, blah.indexOf("</span>"))
|
json["presence"] = blah.substring(0, blah.indexOf("</span>"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (html.includes("persona")) {
|
||||||
|
var blah = html.substring(html.indexOf("persona"), html.length)
|
||||||
|
json.username = blah.substring(blah.indexOf(">") + 1, blah.indexOf("</span>"))
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
if (prevGame != json.name) {
|
||||||
prevGame = json.name
|
prevGame = json.name
|
||||||
startTime = Date.now()
|
startTime = Date.now()
|
||||||
|
@ -58,8 +74,10 @@ function update() {
|
||||||
details: `Playing ${json.name}`,
|
details: `Playing ${json.name}`,
|
||||||
state: json.presence,
|
state: json.presence,
|
||||||
startTimestamp: startTime,
|
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") {
|
if (json.gameName == "nothing") {
|
||||||
|
|
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -1,9 +1,13 @@
|
||||||
{
|
{
|
||||||
"name": "discordUpdater",
|
"name": "steamrpc",
|
||||||
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
|
"name": "steamrpc",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "GPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord-rpc": "^4.0.1"
|
"discord-rpc": "^4.0.1"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
"description": "SteamRPC pulls your game and presence from Steam and puts it onto discord.",
|
"description": "SteamRPC pulls your game and presence from Steam and puts it onto discord.",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"devDependencies": {},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node index.js"
|
"test": "node index.js"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue