This R package integrates Discord Rich Presence with RStudio, allowing you to display the R script you are currently editing in your Discord status. It automatically updates as you switch between files, similar to the VS Code "vscord" extension.
- Automatic Detection: Shows the currently active file in the RStudio editor.
- Real-Time Updates: Status updates within seconds of switching files.
- Silent & Efficient: Runs in the background with minimal performance impact.
- Easy Setup: A one-time setup command is all that's needed.
- Cross-Platform: Works on Windows, macOS, and Linux.
- RStudio Addins: Convenient menu options to start/stop the integration.
- Python 3.6+ must be installed and accessible from your system PATH
- Discord desktop application must be running
- RStudio (obviously!)
Option 1: From R-universe (Easiest)
# Install using standard install.packages()
install.packages('discordrpc', repos = 'https://devon7y.r-universe.dev')Option 2: From GitHub
# Install from GitHub using devtools
devtools::install_github("devon7y/rstudio-discord-rpc")Option 3: From CRAN (pending approval)
# Once approved on CRAN, you'll be able to install with:
install.packages("discordrpc")Option 4: Install Locally
# Install from a local copy
devtools::install("/path/to/rstudio-discord-rpc")After installation, run the setup command:
discordrpc::setup()This will:
- Check for Python and install if needed
- Install the
pypresencePython library - Configure your
.Rprofileto auto-start the integration
Restart RStudio for the changes to take effect.
Once installed and set up, the integration runs automatically. There are no further steps required. Your Discord status will show the file you are editing whenever RStudio is open.
You can manually control the integration using:
# Start the integration
discordrpc::start()
# Stop the integration
discordrpc::stop()
# Re-run setup
discordrpc::setup()The package also provides RStudio Addins accessible from the Addins menu:
- Start Discord Rich Presence
- Stop Discord Rich Presence
- Setup Discord Rich Presence
The package uses a background R process with the later package to periodically check the active file in the RStudio editor. When a file change is detected, it writes to a communication file that a lightweight Python script monitors. The Python script then communicates with the local Discord client via its Rich Presence API using the pypresence library.
This approach is necessary because R cannot directly interface with Discord's IPC socket.
The setup script adds the following to your .Rprofile:
## Discord Rich Presence Integration
suppressMessages(suppressWarnings(library(discordrpc)))
suppressMessages(discordrpc::start())
## End Discord Rich PresenceYou can manually remove these lines to disable auto-start.
Ensure Python is installed and its location is included in your system's PATH environment variable.
If the automatic installation fails, open a terminal or command prompt and run:
python -m pip install pypresence
# Or if you get permission errors:
python -m pip install pypresence --break-system-packages- Make sure Discord is running
- Check that you have enabled "Display current activity as a status message" in Discord's settings (User Settings > Activity Privacy)
- Ensure both
rstudioapiandlaterpackages are installed - Check that the Python script exists:
system.file("python", "update_presence.py", package = "discordrpc") - Try running
discordrpc::setup()again
- Uses
taskkillto stop the Python process - May show command prompt windows briefly when starting
- Uses
pkillto stop the Python process - Uses
nohupfor background process execution
Inspired by the MATLAB Discord Rich Presence plugin and VS Code Discord extensions.
MIT License - see LICENSE file for details.
