This fork fixes an issue with Thunderstorm010's fork where an empty button array is passed in if no buttons are present, resulting in no rich presence being shown. (TLDR: You are no longer required to have buttons added in order for your rich presence to show.)
Connect locally to the Discord client using IPC for a subset of RPC features like Rich Presence and Activity Join/Spectate
- Setting Rich Presence
- Listen for Join, Spectate, and Join-Request events
- Detect and specify priority for client build (Stable, PTB, Canary)
- 100% Java
First you'll need to add this project as a dependency. If you're using maven:
<dependency>
<groupId>com.github.hapily04</groupId>
<artifactId>DiscordIPC</artifactId>
<version>3389be879d</version>
</dependency>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
With gradle:
dependencies {
implementation 'com.github.hapily04:DiscordIPC:3389be879d'
}
repositories {
...
maven { url 'https://jitpack.io' }
}
Quick example, assuming you already have a GUI application
IPCClient client = new IPCClient(345229890980937739L);
client.setListener(new IPCListener(){
@Override
public void onReady(IPCClient client)
{
RichPresence.Builder builder = new RichPresence.Builder();
builder.setState("West of House")
.setDetails("Frustration level: Over 9000")
.setStartTimestamp(OffsetDateTime.now())
.setLargeImage("canary-large", "Discord Canary")
.setSmallImage("ptb-small", "Discord PTB")
.setParty("party1234", 1, 6)
.setMatchSecret("xyzzy")
.setJoinSecret("join")
.setSpectateSecret("look");
client.sendRichPresence(builder.build());
}
});
client.connect();
- Monster Hunter Gathering Hall App - App for displaying in-game info for a non-PC game series
The official RPC bindings can be found here: https://github.com/discordapp/discord-rpc
A Java wrapper for the official bindings is available here: https://github.com/MinnDevelopment/Java-DiscordRPC