jagrosh / discordipc Goto Github PK
View Code? Open in Web Editor NEWConnect locally to the Discord client using IPC for a subset of RPC features like Rich Presence and Activity Join/Spectate
License: Apache License 2.0
Connect locally to the Discord client using IPC for a subset of RPC features like Rich Presence and Activity Join/Spectate
License: Apache License 2.0
How do you connect this to the app you want to use (like IntelliJ IDEA)
So this is a pretty strange error. It's my first time working with DiscordIPC, so it's possible I'm just not doing something. However, it seems to be the fault of a class here. Basically, I'm working on a Minecraft mod that will work in conjunction with the server I run, and one of its functions is to show Rich Presence. However, when I try to start the game using the mod, it crashes trying to startup.
Here's what the crash report says the error is:
...
Caused by: java.lang.RuntimeException: org.newsclub.net.unix.AFUNIXSocketException: Cannot find method "setCreated" in java.net.Socket. Unsupported JVM?
at com.jagrosh.discordipc.entities.pipe.Pipe.createPipe(Pipe.java:167)
at com.jagrosh.discordipc.entities.pipe.Pipe.openPipe(Pipe.java:67)
at com.jagrosh.discordipc.IPCClient.connect(IPCClient.java:116)
at com.playbuilderverse.builderversetweaks.BuilderverseTweaks.connect(BuilderverseTweaks.java:29)
at com.playbuilderverse.builderversetweaks.BuilderverseTweaks.onInitialize(BuilderverseTweaks.java:17)
at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:47)
... 12 more
Caused by: org.newsclub.net.unix.AFUNIXSocketException: Cannot find method "setCreated" in java.net.Socket. Unsupported JVM?
at org.newsclub.net.unix.NativeUnixSocket.setCreated(Native Method)
at org.newsclub.net.unix.AFUNIXSocket.<init>(AFUNIXSocket.java:36)
at org.newsclub.net.unix.AFUNIXSocket.newInstance(AFUNIXSocket.java:54)
at com.jagrosh.discordipc.entities.pipe.UnixPipe.<init>(UnixPipe.java:45)
at com.jagrosh.discordipc.entities.pipe.Pipe.createPipe(Pipe.java:163)
... 17 more
Not sure if it's possible that I'm running an unsupported JVM, because I'm running it straight from a build configuration in IntelliJ IDEA which is using Java 17. I can send the full crash report, just ask me for it.
Whenever I try to use this project with gradle, it cannot find it.
Heres the error:
Could not find com.jagrosh:DiscordIPC:0.4. Searched in the following locations: - file:/Users/myuser/.gradle/caches/forge_gradle/bundeled_repo/com/jagrosh/DiscordIPC/0.4/DiscordIPC-0.4.pom - file:/Users/myuser/.gradle/caches/forge_gradle/bundeled_repo/com/jagrosh/DiscordIPC/0.4/DiscordIPC-0.4.jar - https://files.minecraftforge.net/maven/com/jagrosh/DiscordIPC/0.4/DiscordIPC-0.4.pom - https://files.minecraftforge.net/maven/com/jagrosh/DiscordIPC/0.4/DiscordIPC-0.4.jar - https://libraries.minecraft.net/com/jagrosh/DiscordIPC/0.4/DiscordIPC-0.4.jar - https://repo.maven.apache.org/maven2/com/jagrosh/DiscordIPC/0.4/DiscordIPC-0.4.pom - https://repo.maven.apache.org/maven2/com/jagrosh/DiscordIPC/0.4/DiscordIPC-0.4.jar Required by: project :
DiscordIPC doesn't work with OSX, keep throwing NoDiscordClientException
object Main {
@JvmStatic
fun main(args: Array<String>) {
val client = IPCClient(384465696496549888L)
client.setListener(object : IPCListener {
override fun onReady(client: IPCClient?) {
val builder = 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()
}
}
Exception in thread "main" java.lang.RuntimeException: java.net.SocketException: Socket file not found: /run/user/1000/snap.intellij-idea-community/discord-ipc-0
at com.jagrosh.discordipc.entities.pipe.Pipe.createPipe(Pipe.java:167)
at com.jagrosh.discordipc.entities.pipe.Pipe.openPipe(Pipe.java:67)
at com.jagrosh.discordipc.IPCClient.connect(IPCClient.java:116)
at com.mrpowergamerbr.powerrp.Main.main(Main.kt:34)
Caused by: java.net.SocketException: Socket file not found: /run/user/1000/snap.intellij-idea-community/discord-ipc-0
at org.newsclub.net.unix.AFUNIXSocketImpl.validateSocketFile(AFUNIXSocketImpl.java:164)
at org.newsclub.net.unix.AFUNIXSocketImpl.connect(AFUNIXSocketImpl.java:154)
at org.newsclub.net.unix.AFUNIXSocket.connect(AFUNIXSocket.java:138)
at org.newsclub.net.unix.AFUNIXSocket.connect(AFUNIXSocket.java:117)
at com.jagrosh.discordipc.entities.pipe.UnixPipe.<init>(UnixPipe.java:46)
at com.jagrosh.discordipc.entities.pipe.Pipe.createPipe(Pipe.java:163)
... 3 more
I'm running the code directly from IDEA, maybe that's why it isn't working? Discord's IPC socket is in ./run/user/1000/discord-ipc-0
on my system
Hello @jagrosh
I'm receiving this error while calling the function IPCClient#close
which it should close everything safety but it appears an exception that I can't handle it by try and catch because it's in a different thread. So, I hope there's a solution for this error.
21:25:26.238 [Thread-11] ERROR com.jagrosh.discordipc.IPCClient - Reading thread encountered an IOException
java.io.IOException: Stream Closed
at java.io.RandomAccessFile.length(Native Method)
at com.jagrosh.discordipc.entities.pipe.WindowsPipe.read(WindowsPipe.java:56)
at com.jagrosh.discordipc.IPCClient.lambda$startReading$0(IPCClient.java:350)
at java.lang.Thread.run(Thread.java:748)
How to fix it that the app crashes when discord isn't opened?
`IPCClient client = new IPCClient(/ID not for you/);
client.setListener(new IPCListener() {
private Minecraft mc;
@Override
public void onReady(IPCClient client) {
RichPresence.Builder builder = new RichPresence.Builder();
builder.setState("Versie: " + getMinecraft().getVersion())
.setDetails("Naam: " + getMinecraft().getSession().getUsername())
.setStartTimestamp(OffsetDateTime.now())
.setLargeImage("monkey-logo", "Client Side Anicheat");
client.sendRichPresence(builder.build());
}
});
try {
client.connect();
} catch (NoDiscordClientException e) {
e.printStackTrace();
}`
accidentally hit enter too quick
When attempting to invoke IPCClient#close
it appears that the IPCClient does not actually close anything.
When building and you do not set party the presence won't show up on discord at all.
This is the third Java API that I try using and it is not even available on jCentral, as written on the README.MD.
Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: \\?\pipe\discord-ipc-0 (All pipe instances are busy)
at com.jagrosh.discordipc.entities.pipe.WindowsPipe.<init>(WindowsPipe.java:45)
at com.jagrosh.discordipc.entities.pipe.Pipe.createPipe(Pipe.java:158)
at com.jagrosh.discordipc.entities.pipe.Pipe.openPipe(Pipe.java:67)
at com.jagrosh.discordipc.IPCClient.connect(IPCClient.java:116)
at xxAROX.PresenceMan.Application.Bootstrap.main(Bootstrap.java:31)
Caused by: java.io.FileNotFoundException: \\?\pipe\discord-ipc-0 (All pipe instances are busy)
at java.base/java.io.RandomAccessFile.open0(Native Method)
at java.base/java.io.RandomAccessFile.open(RandomAccessFile.java:344)
at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:259)
at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:213)
at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:127)
at com.jagrosh.discordipc.entities.pipe.WindowsPipe.<init>(WindowsPipe.java:43)
... 4 more
Process finished with exit code 1
The app that I made crashes when discord isn't opened
Exception in thread "main" java.lang.RuntimeException: org.newsclub.net.unix.AFUNIXSocketException: Cannot find method "setCreated" in java.net.Socket. Unsupported JVM?
at com.jagrosh.discordipc.entities.pipe.Pipe.createPipe(Pipe.java:167)
at com.jagrosh.discordipc.entities.pipe.Pipe.openPipe(Pipe.java:67)
at com.jagrosh.discordipc.IPCClient.connect(IPCClient.java:116)
at Main.main(Main.java:22)
Caused by: org.newsclub.net.unix.AFUNIXSocketException: Cannot find method "setCreated" in java.net.Socket. Unsupported JVM?
at org.newsclub.net.unix.NativeUnixSocket.setCreated(Native Method)
at org.newsclub.net.unix.AFUNIXSocket.(AFUNIXSocket.java:36)
at org.newsclub.net.unix.AFUNIXSocket.newInstance(AFUNIXSocket.java:54)
at com.jagrosh.discordipc.entities.pipe.UnixPipe.(UnixPipe.java:45)
at com.jagrosh.discordipc.entities.pipe.Pipe.createPipe(Pipe.java:163)
... 3 more
Code that i use:
import com.jagrosh.discordipc.IPCListener
import com.jagrosh.discordipc.entities.RichPresence
import com.jagrosh.discordipc.entities.pipe.PipeStatus
import java.time.OffsetDateTime
fun main() {
try {
val client = IPCClient(client_id) //replaced for secret
val rpcBuilder = RichPresence.Builder()
.setLargeImage("default", "asdf")
.setSmallImage("minecraft_logo", "asdf")
client.connect()
rpcBuilder.setStartTimestamp(OffsetDateTime.now())
val richPresence = rpcBuilder
.setDetails("asdf")
.setState("하이요")
.build()
client.sendRichPresence(richPresence)
}
}
main()
Result:
state with unicode string(in this case, "하이요") got seems broken. tried
.setState(String("하이요".toByteArray(), Charset.forName("euc-kr")))
and
.setState(String("하이요".toByteArray(), Charset.forName("cp949")))
but it didn't work for me :(
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.