A lightweight, configurable Discord Rich Presence client written in Go.
- ✅ Fully configurable via
config.json
- ✅ Automatically refreshes presence at runtime
- ✅ Custom data embedding via BASH scripts
- ✅ No OAuth required
- Go 1.18+
- Discord desktop client (must be running)
- Unix-based OS (for default IPC path)
Note: Windows support is not quite there yet, but it is planned.
git clone https://github.com/casperjdev/go-rpc
cd go-rpc
go build -o go-rpc .
Create an application on the Discord Developer Portal
Save the application ID aswell as set the name of the application. This will be the name of the activity on Discord.
All of the images you will be using should also be saved there.
Create a config.json
file in the same directory as the build output.
The schema is adjacent to the one used by Discord's Game SDK. Same constraints apply:
Method 1: Pass bash commands
"{kernel}": "uname -sr"
Method 2: Pass path to runnable script
./scripts/uptime.sh
Static Constants are fetched once during presence initialization and never again (data that never changes).
Dynamic Constants are fetched whenever the presence updates (for things like time, etc.).
Notes:
- You can name keys however you want (reccomended to use curly braces)
- Scripts must be executable (
chmod +x
) and they need to output exactly one line tostdout
- It is reccomended to not use performance intensive scripts as they may be re-ran on every presence update.
Run the built executable with Discord open
You need to be using the desktop client for Discord. Web Discord has no way to communicate through IPC.
If you want to for example automatically run this app when discord launches on your device you might want to use a systemd service.
Discord runs per-user, not globally. So your service must run as the same user who is logged into the graphical session (the one running Discord).
Use a user-level service, not a system-wide one.
A reccomended setup is to have a service run a watcher script that launches the app based on Discord being active
.../.../watcher.sh
#!/bin/bash APP_NAME="go-rpc" APP_CMD="path/to/app/go-rpc" cleanup() { echo "Watcher stopped. Cleaning up..." pkill -x "$APP_NAME" exit 0 } trap cleanup EXIT INT TERM HUP while true; do if pgrep -x Discord > /dev/null; then if ! pgrep -x "$APP_NAME" > /dev/null; then echo "Starting Go app..." "$APP_CMD" & fi else if pgrep -x "$APP_NAME" > /dev/null; then echo "Stopping Go app..." pkill -x "$APP_NAME" fi fi sleep 2 done
.../systemd/user/go-rpc.service
[Unit] Description=Discord Go App Watcher After=graphical-session.target PartOf=graphical-session.target [Service] Type=simple WorkingDirectory=/path/to/watcher ExecStart=/path/to/watcher/watcher.sh Restart=on-failure KillMode=control-group TimeoutStopSec=5 RemainAfterExit=no [Install] WantedBy=default.targetMake sure the watcher is runnable:
chmod +x .../.../discord-watcher.sh
If you wish to fine-tune certain things like update and heartbeat intervals, the code is up for grabs.
Tips:
- Make sure to not crank up the update rate too high or else your client might get flagged and blocked.
- if you prefer to write Go code instead of BASH code to write scripts for constants, you can do so by extending the
getConstants()
function inconstants.go
and the re-building your app