vatuu / discord-rpc Goto Github PK
View Code? Open in Web Editor NEWJava Wrapper of the Discord-RPC Library for Discord Rich Presence.
License: MIT License
Java Wrapper of the Discord-RPC Library for Discord Rich Presence.
License: MIT License
Describe the bug
Fails to build.
Error
discord-rpc\src\main\java\net\arikia\dev\drpc\DiscordRPC.java:182:21
java: cannot find symbol
symbol: variable f
location: class net.arikia.dev.drpc.DiscordRPC
Versions (Must be completed):
Additional info
Looks like commit 1fd4d69 broke this.
Heyho,
i've saw that the issue i have isn't new. So i opened a new issue.
This happens when i call the initialize Method:
Caused by: java.lang.NullPointerException at net.arikia.dev.drpc.DiscordRPC.copyFile(DiscordRPC.java:204) at net.arikia.dev.drpc.DiscordRPC.loadDLL(DiscordRPC.java:144) at net.arikia.dev.drpc.DiscordRPC.<clinit>(DiscordRPC.java:16) ... 48 more
I've deleted all discord-rpc files and directories in my temp folder.
Thanks for help
Here is my handler for it
.setJoinGameEventHandler(new JoinGameCallback() {
@Override
public void apply(String secret) {
WizardGame.instance.getClient().sendMessage(new DiscordJoinGameMessage(secret));
Gdx.app.log("DiscordJoinGame", "Secret " + secret);
}
})
This is my initialization code:
String appId = "XXXXXXXXX";
DiscordRPC.discordInitialize(appId, handlers, true);
doDiscordEvents();
DiscordRPC.discordClearPresence();
DiscordRPC.discordUpdatePresence(new DiscordRichPresence());
discordThread = new Thread(new Runnable() {
@Override
public void run() {
while (!Thread.currentThread().isInterrupted()) {
try {
DiscordRPC.discordRunCallbacks();
Gdx.app.log("discordEvents", "Polling...");
Thread.sleep(2000);
} catch (InterruptedException e) {}
}
}
}, "Discord-Event-Poll");
discordThread.setDaemon(true);
discordThread.start();
Why isn't the event firing?
Hello, I am trying to use this library in my application, but upon calling DiscordRPC.discordInitialize()
with a null
applicationID
the library prints this in the error output stream:
sh: 1: Syntax error: "(" unexpected
Maybe a more meaningful error could be printed?
Contact me VIA discord please Phil#0004
OS: Windows 10 pro version 10.0.17134 N/A Build 17134
SDK version: v1.8.0_191
In the the start/main class: https://pastebin.com/GRYQ9fjV
Stacktrace errors: https://pastebin.com/gNesPve5
Hello. I am using the new version and i am on windows 11
but oftenen my discord rpc dont show up. I also use the example
package at.eruxmod.utils.application.discord;
import net.arikia.dev.drpc.DiscordEventHandlers;
import net.arikia.dev.drpc.DiscordRPC;
import net.arikia.dev.drpc.DiscordRichPresence;
import javax.swing.*;
import java.awt.*;
import java.util.Scanner;
public class DiscordRP {
private static boolean ready = false;
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
JFrame frame = new JFrame("Test");
JLabel text = new JLabel("Now goto Discord and set your active game to: '" + frame.getTitle() + "'");
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
int width = gd.getDisplayMode().getWidth();
int height = gd.getDisplayMode().getHeight();
frame.getContentPane().setLayout(new FlowLayout());
frame.getContentPane().setBackground(new Color(114, 137, 218));
frame.getContentPane().add(text, SwingConstants.CENTER);
frame.setResizable(true);
frame.setSize(width/4, height/4);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
System.out.println("Closing Discord hook.");
DiscordRPC.discordShutdown();
}));
initDiscord();
int score = 0;
System.out.println("Running callbacks...");
while (true) {
DiscordRPC.discordRunCallbacks();
if(!ready)
continue;
System.out.print("> ");
Scanner in = new Scanner(System.in);
String input = in.nextLine();
if (!input.equalsIgnoreCase("shutdown")) {
if (input.equalsIgnoreCase("test")) {
score++;
DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder("Score: ");
presence.setDetails("Running Test");
DiscordRPC.discordUpdatePresence(presence.build());
} else {
System.out.println("Unknown Command: " +
"\n\nAvailable Commands:" +
"\ntest - Test.\nshutdown - End this test peacefully.");
}
} else {
frame.dispose();
System.exit(0);
}
}
}
private static void initDiscord() {
DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler((user) -> {
DiscordRP.ready = true;
System.out.println("Welcome " + user.username + "#" + user.discriminator + ".");
DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder("Score: ");
presence.setDetails("Running Test");
DiscordRPC.discordUpdatePresence(presence.build());
}).build();
DiscordRPC.discordInitialize("415885161457123338", handlers, false);
DiscordRPC.discordRegister("415885161457123338", "");
}
}
No Errors
How do I add an image to the RPC because I can't.
Describe the bug
when loading discord rpc the program crashes
Source
// initialize Discord Rich Presence
DiscordEventHandlers handlers = new DiscordEventHandlers();
DiscordRPC.discordInitialize("968887179994624100", handlers, true);
DiscordRichPresence presence = new DiscordRichPresence();
Error
Caused by: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.read(byte[])" because "input" is null
Versions (Must be completed):
openjdk version "18" 2022-03-22 OpenJDK Runtime Environment 22.3 (build 18+37) OpenJDK 64-Bit Server VM 22.3 (build 18+37, mixed mode, sharing)
1.5.0
Additional info
I used pom
No idea if this is on my end but y'know
It seems way too small and refuses to load with the error Exception in thread "main" java.lang.UnsatisfiedLinkError: F:\Sean\AppData\Local\Temp\discord-rpc.jar\discord-rpc.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
is that possible to add button to the status? for example button to youtube link
๐ Describe the bug
Uh oh! ๐ฑ Whenever I try to run my Minecraft Fabric 1.19.3 game with my cool DiscordRPC mod, it crashes and gives me a super scary error message! ๐ญ The error says java.lang.RuntimeException: Could not execute entrypoint stage 'main' due to errors, provided by 'neon'!, and then there's some stuff about java.lang.UnsatisfiedLinkError: 'java.lang.String com.mod.shadow.com.sun.jna.Native.getNativeVersion()' which I don't really understand... but basically, my mod is broken and I can't play my game with DiscordRPC.
๐ Source
public class DiscordRPCManager {
private static final String APPLICATION_ID = "your_application_id_here";
private static final DiscordRichPresence presence = new DiscordRichPresence();
private static DiscordRPC rpc;
private static String currentDetails = "";
private static String currentServer = "";
private static long startTime = 0;
public static void init() {
Euphoria.LOGGER.info("Launching DiscordRPC");
rpc = new DiscordRPC();
rpc.discordInitialize(APPLICATION_ID, new DiscordEventHandlers(), true, "");
presence.largeImageKey = "";
presence.largeImageText = "";
updatePresence();
}
public static void shutdown() {
rpc.discordShutdown();
}
public static void updateTimestamps() {
startTime = System.currentTimeMillis() / 1000;
presence.startTimestamp = startTime;
rpc.discordUpdatePresence(presence);
}
}
๐จ Error
Here's the error message I get when I try to run my game with the mod:
java.lang.RuntimeException: Could not execute entrypoint stage 'main' due to errors, provided by 'neon'!
at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.lambda$invoke0$0(EntrypointUtils.java:51)
at net.fabricmc.loader.impl.util.ExceptionUtil.gatherExceptions(ExceptionUtil.java:33)
at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:49)
at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke(EntrypointUtils.java:35)
at net.fabricmc.loader.impl.game.minecraft.Hooks.startClient(Hooks.java:52)
at net.minecraft.class_310.<init>(class_310.java:465)
at net.minecraft.client.main.Main.method_44604(Main.java:205)
at net.minecraft.client.main.Main.main(Main.java:51)
at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:462)
at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
Caused by: java.lang.UnsatisfiedLinkError: 'java.lang.String com.mod.shadow.com.sun.jna.Native.getNativeVersion()'
at com.mod.shadow.com.sun.jna.Native.getNativeVersion(Native Method)
at com.mod.shadow.com.sun.jna.Native.<clinit>(Native.java:192)
at com.mod.shadow.com.sun.jna.Pointer.<clinit>(Pointer.java:54)
at com.mod.shadow.com.sun.jna.Structure.<clinit>(Structure.java:2130)
at com.mod.elements.discord.DiscordRPCManager.<clinit>(DiscordRPCManager.java:11)
at com.mod.Mod.<clinit>(Mod.java:65)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at net.fabricmc.loader.impl.util.DefaultLanguageAdapter.create(DefaultLanguageAdapter.java:50)
at net.fabricmc.loader.impl.entrypoint.EntrypointStorage$NewEntry.getOrCreate(EntrypointStorage.java:117)
at net.fabricmc.loader.impl.entrypoint.EntrypointContainerImpl.getEntrypoint(EntrypointContainerImpl.java:53)
at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:47)
... 8 more
๐ Versions (Must be completed):
OS Ver: Windows 11
Java Version: 17
Library Version: 1.6.2
๐ Additional info
I'm not sure if this is relevant, but I'm using the latest version of the DiscordRPC library. Thanks for your help, and I hope we can get this fixed soon so I can show off my cool mod to all my friends! ๐
๐ค So, I reached out to Vatuu about the issue you're having with their DiscordRPC library, and they've confirmed that they're currently working on a fix for it! ๐ ๏ธ. That's great news, right? ๐ In the meantime, why not take a break and play some Minecraft without the DiscordRPC mod? ๐ฎ It might not be as cool, but at least you won't have to deal with that pesky error message! ๐. Keep an eye out for updates from Vatuu on when the fix will be available. Hopefully, it won't be too long before you can start showing off your awesome mod to your friends again! ๐ค
I am not an expert on this, but here is my problem.
My app uses jna version 5.0.0.
Discord-rpc uses version 4.5.1
When running my app it loads the jna lib from the discord library making it crash with NoSuchMethodError.
The solution to the issue is the library using the shade plusgin as described here https://labs.spotify.com/2015/09/01/java-linking/ .
If I look into your maven pom.xml then I see you use that plug-in
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
So there should not be any problems but the classes are never the less normally included in the discord-rpc jar and i would expect them to be under net.arikia.dev path or something so my app does not load them as jna. I do admit I got not much of an idea of this shading plugin...
Maybe I will have a look into it, but would be cool if somebody of u could do it I have a really hard time reading into that shade-plugin docu.
Describe the bug
When this library calls the ReadyEvent from the discordEventHandlers the DiscordUser
can return null. I used this code:
builder.setReadyEventHandler((usr)->{
DRPCLog.Info("READY! Logged in as "+usr.username);
});
This causes this error:
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:123]: JNA: Callback de.erdbeerbaerlp.discordrpc.Discord$$Lambda$52/1650171715@7a4764bb threw the following exception:
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: java.lang.NullPointerException
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: at de.erdbeerbaerlp.discordrpc.Discord.lambda$0(Discord.java:57)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: at java.lang.reflect.Method.invoke(Method.java:498)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:520)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:551)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: at com.sun.jna.Native.invokeVoid(Native Method)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: at com.sun.jna.Function.invoke(Function.java:408)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: at com.sun.jna.Function.invoke(Function.java:354)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: at com.sun.jna.Library$Handler.invoke(Library.java:244)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: at net.arikia.dev.drpc.$Proxy28.Discord_RunCallbacks(Unknown Source)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: at net.arikia.dev.drpc.DiscordRPC.discordRunCallbacks(DiscordRPC.java:96)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: at de.erdbeerbaerlp.discordrpc.Discord$1.run(Discord.java:30)
Source
Versions (Must be completed):
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
1.6.2
Additional info
Minecraft Version: 1.12.2
Forge Version: 14.23.4.2705
By default, the action is playing, is there a way to change that?
On Windows, dynamic libraries fail to load when users have non-ascii characters in their usernames. I looked into it and found the root cause. It appears System.load()
does not accept non-ascii characters in the path. It appears to be a known issue: https://bugs.openjdk.java.net/browse/JDK-8195129
I've implemented a workaround by parametrizing the DLL path instead of defaulting to their home directory.
Describe the bug
All special characters will be displayed as a question mark
Example (with a japaneese level name as an UTF-8 String):
Versions (Must be completed):
java version "1.8.0_211" Java(TM) SE Runtime Environment (build 1.8.0_211-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
1.6.2
Or more like; how do acquire it. I dont see a way; and using the client ID its not working.
I have integrated Discord RPC functionality in my game using the jar file from the releases page (v1.6.2). It works just fine, but when I launch two instances of my game, the old instance crashes with a SIGSEGV. When I remove the Discord RPC related code, the game doesn't crash when launching multiple instances so it's something related to this.
This is basically what my code looks like:
DiscordRPC.discordInitialize(applicationID, null, false);
richPresence = new DiscordRichPresence.Builder("")
.setBigImage("logo", "v0.0.1")
.setStartTimestamps(System.currentTimeMillis())
.build();
richPresence.state = stateStr;
DiscordRPC.discordUpdatePresence(richPresence);
Versions:
openjdk version "1.8.0_252"
v1.6.2
Would it be possible to set this up to work with gradle?
Hi, first off thank you for this amazing rpc :)
But I have seem to encountered an issue, when people launch a second instance of the application, it will throw an error process already in use (this also happens if discord rpc is in use by something else right now).
No issues there, but it throws a FileNotFoundException which I attempted to catch to neatly print that the RPC is disabled opposed to the stacktrace, and also disable usage for it later down the road.
java.io.FileNotFoundException: C:\Users\Alex\AppData\Local\Temp\discord-rpc\discord-rpc.dll (The process cannot access the file because it is being used by another process) at java.io.FileOutputStream.open0(Native Method) at java.io.FileOutputStream.open(Unknown Source) at java.io.FileOutputStream.<init>(Unknown Source) at java.io.FileOutputStream.<init>(Unknown Source) at net.arikia.dev.drpc.DiscordRPC.openOutputStream(DiscordRPC.java:186) at net.arikia.dev.drpc.DiscordRPC.loadDLL(DiscordRPC.java:152) at net.arikia.dev.drpc.DiscordRPC.<clinit>(DiscordRPC.java:21) at com.runescape.Client.main(Client.java:4126)
Ive tried using a normal Try/Catch for FileNotFoundException but then Eclipse will tell me that this code will never throw this exception (except it already did), so instead I setup a general Exception clause, which seems completely ignored (the error message is never printed)
`try {
DiscordEventHandlers handlers = new DiscordEventHandlers();
DiscordRPC.discordInitialize("123", handlers, true);
DiscordRichPresence rich = new DiscordRichPresence.Builder("At login screen").build();
DiscordRPC.discordUpdatePresence(rich);
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
DiscordRPC.discordShutdown();
}
}));
} catch (Exception e) {
System.out.println("Failed connecting to discord: "+ e.getClass());
}`
java.lang.NullPointerException
at net.arikia.dev.drpc.DiscordRPC.loadDLL(DiscordRPC.java:158)
at net.arikia.dev.drpc.DiscordRPC.(DiscordRPC.java:26)
Inputstream is null, how should I initialise it?
Could this be added to a maven repository for easier development?
Describe the bug
I am making adding RPC to my minecraft client. When I run in debug the RPC works but when I implement to the launcher i get all those errors and I can't figure out why. Any help is appreciated.
Source
package EfeClient;
public class Client {
private static final Client INSTANCE = new Client();
public static final Client getInstance() {
return INSTANCE;
}
private DiscordRP discordRP = new DiscordRP();
public void init() {
discordRP.start();
}
public void shutdown() {
discordRP.shutdown();
}
public DiscordRP getDiscordRP() {
return discordRP;
}
}
Error
Versions (Must be completed):
java.lang.NoClassDefFoundError: net/arikia/dev/drpc/callbacks/ReadyCallback
at EfeClient.Client.(Client.java:10)
at EfeClient.Client.(Client.java:5)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:470)
at net.minecraft.client.Minecraft.run(Minecraft.java:401)
at net.minecraft.client.main.Main.main(Main.java:113)
Caused by: java.lang.ClassNotFoundException: net.arikia.dev.drpc.callbacks.ReadyCallback
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 5 more
-- Head --
Stacktrace:
at EfeClient.Client.(Client.java:10)
at EfeClient.Client.(Client.java:5)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:470)
-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.run(Minecraft.java:401)
at net.minecraft.client.main.Main.main(Main.java:113)
-- System Details --
Details:
Minecraft Version: 1.8.8
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_51, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 87987328 bytes (83 MB) / 167772160 bytes (160 MB) up to 2147483648 bytes (2048 MB)
JVM Flags: 8 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
Launched Version: EfeClient
LWJGL: 2.9.4
OpenGL: ERROR RuntimeException: No OpenGL context found in the current thread.
GL Caps:
Using VBOs: ERROR NullPointerException: null
Is Modded: Very likely; Jar signature invalidated
Type: Client (map_client.txt)
Resource Packs: ERROR NullPointerException: null
Current Language: ERROR NullPointerException: null
Profiler Position: N/A (disabled)
CPU:
Additional info
java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389) at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767) Caused by: java.lang.UnsatisfiedLinkError: /media/storage/Programming/PersonalProjects/KingTux/null/discord-rpc.jar/discord-rpc.so: /media/storage/Programming/PersonalProjects/KingTux/null/discord-rpc.jar/discord-rpc.so: failed to map segment from shared object at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824) at java.lang.Runtime.load0(Runtime.java:809) at java.lang.System.load(System.java:1086) at net.arikia.dev.drpc.DiscordRPC.loadDLL(DiscordRPC.java:106) at net.arikia.dev.drpc.DiscordRPC.<clinit>(DiscordRPC.java:21) at me.kingtux.kingtux.Main.main(Main.java:30) ... 11 more Exception running application me.kingtux.kingtux.Main
Code
package me.kingtux.kingtux;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import net.arikia.dev.drpc.DiscordEventHandlers;
import net.arikia.dev.drpc.DiscordRPC;
import net.arikia.dev.drpc.DiscordRichPresence;
import net.arikia.dev.drpc.callbacks.ReadyCallback;
import javafx.stage.Stage;
import java.util.Scanner;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("window.fxml"));
primaryStage.setTitle("KingTux.jar");
primaryStage.setScene(new Scene(root, 600, 275));
primaryStage.show();
}
public static void main(String[] args) {
System.out.println("Check2");
DiscordEventHandlers handler = new DiscordEventHandlers();
handler.ready = new DiscordPresense();
DiscordRPC.DiscordInitialize("400851884899827714", handler, true);
DiscordRPC.DiscordRunCallbacks();
Scanner scanner = new Scanner(System.in);
launch(args);
}
}
I may be just really bad at reading, but I don't believe that there's a way to use an authorization code in this wrapper. Is this true? If not how can I use an oAuth code to use RPC?
Discord Rich Presence is deprecated and was replaced with the game sdk. Would it not be an easy to to the same with that in the way you did it here with Discord Rich Presence sdk.
Apologies if this isn't the right place (or person) to ask.
I'm interested in making a "bridge" app in Java that hooks into various 3rd-party apps/games to provide rich presence in Discord. Something similar to SimplePresence but my own spin on it (I know noting about JavaScript but enough about JNA).
But I am concerned about Discord's stance on "self-botting" and how it's a bannable offense.
Is Rich Presence something that only game/app developers are allowed to use for their own applications? Or is Rich Presence via RPC not considered "self-botting" at all? What do you think?
I've tried to research this as best I can, but am surprised that nobody has really looked into it. Closest thing I found was a request for Rich Presence support in a python.py request, but it was shot-down by someone for being self-botting.
Thanks for any advice you have.
If I wanna set start and end time of a game. I am forced to set start and end time by the parameters being long and not Long. Our game https://faforever.com/ does not have a fixed end time, so I want to be able to only set a start time but no end time.
Suggestion: Move native libs into a separate directory in .jar
For now, jar application with extracted discord-rpc library seems unstructured (we have few dirs with single files).
Maybe just put all libs into one directory called natives?
Am planning on writing a Scala wrapper around this and using that to make an IntelliJ plugin for Rich Presence, is this lib working fully yet?
Here is the error:
Error Exception in thread "Client thread" java.lang.ExceptionInInitializerError
at bedless.RPC.start(RPC.java:24)
at net.minecraft.client.Minecraft.(Minecraft.java:384)
at net.minecraft.client.main.Main.main(Main.java:113)
Caused by: java.lang.NullPointerException
at net.arikia.dev.drpc.DiscordRPC.copyFile(DiscordRPC.java:165)
at net.arikia.dev.drpc.DiscordRPC.loadDLL(DiscordRPC.java:153)
at net.arikia.dev.drpc.DiscordRPC.(DiscordRPC.java:21)
... 3 more
Here is the code
package bedless;
import java.util.Date;
import com.ibm.icu.text.SimpleDateFormat;
import net.arikia.dev.drpc.DiscordEventHandlers;
import net.arikia.dev.drpc.DiscordRPC;
import net.arikia.dev.drpc.DiscordRichPresence;
import net.arikia.dev.drpc.DiscordUser;
import net.arikia.dev.drpc.callbacks.ReadyCallback;
public class RPC extends Client {
DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler(new ReadyCallback() {
@Override
public void apply(DiscordUser user) {
}
}).build();
public void start() {
DiscordRPC.discordInitialize("858420957680762881", handlers, true);
DiscordRichPresence rich = new DiscordRichPresence.Builder("Idle").setBigImage("bedlessmain", "bedlessmain").setStartTimestamps(System.currentTimeMillis()).build();
DiscordRPC.discordUpdatePresence(rich);
}
public void stop() {
DiscordRPC.discordShutdown();
}
public void joinServer() {
DiscordRichPresence rich = new DiscordRichPresence.Builder("Idle").setBigImage("bedlessmain", "bedlessmain").build();
DiscordRPC.discordUpdatePresence(rich);
}
}
RichPresenceManager l. 48:
DiscordRPC.discordInitialize("- id -", eventHandlers, true);
OS: Linux 4.13.0-45-generic (KDE neon) | Java: 10.0.1
Made a simple Console app RPC, It works for me but not for everyone else, whitelisted my friend in the project page, but still not working for him
Please reply ASAP
Describe the bug
On Windows, the build from the recent commit (1f82937) crashes with a java.lang.UnsatisfiedLinkError
. I'm using api 'com.github.Vatuu:discord-rpc:1f82937'
in gradle. The crash occurs when running a single instance of my game itself.
Using a version before #49 was merged works without any issues. For instance, api 'com.github.Vatuu:discord-rpc:0293d57'
works without crashing for a single instance of the game.
Source
DiscordRPC.discordInitialize(applicationID, null, false);
Error
(Trimmed to exclude uneccessary information)
Exception in thread "Game Application" java.lang.UnsatisfiedLinkError: Unable to load library 'discord-rpc': Native library (win32-x86-64/discord-rpc.dll) not found in resource path ([file:/C:/Users/jas/Downloads/Game.jar])
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:303)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:427)
at com.sun.jna.Library$Handler.<init>(Library.java:179)
at com.sun.jna.Native.loadLibrary(Native.java:569)
at com.sun.jna.Native.loadLibrary(Native.java:544)
at net.arikia.dev.drpc.DiscordRPC$DLL.<clinit>(DiscordRPC.java:222)
at net.arikia.dev.drpc.DiscordRPC.discordInitialize(DiscordRPC.java:32)
Versions (Must be completed):
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)
Additional info
This issue happens only on Windows. On Linux, both the recent commit and the older one works without crashing for a single instance.
The documentation provided in the READ ME is not very comprehensive and is not up-to-date.
Apparently DiscordEventHandler is not in existence, so I cannot get very far.
Can not set startTimestamp via DiscordRichPresence.Builder
As seen in #5 , i'm still getting that same error, even using the latest discord and discord-rpc version.
I'm using maven by the way.
Describe the bug
Typo in README
Source
Readme
Error
public void startup(){
DiscordEventHandlers handlers = new DiscordEventHandler.Build().setReadyEventHandler((user) -> {
System.out.println("Welcome " + user.username + "#" + user.discriminator + "!");
}).build();
DiscordRPC.initialize("1234567890", handler, true);
}
->
public void startup(){
DiscordEventHandlers handlers = new DiscordEventHandler.Build().setReadyEventHandler((user) -> {
System.out.println("Welcome " + user.username + "#" + user.discriminator + "!");
}).build();
DiscordRPC.initialize("1234567890", handlers, true);
}
or
public void startup(){
DiscordEventHandlers handler = new DiscordEventHandler.Build().setReadyEventHandler((user) -> {
System.out.println("Welcome " + user.username + "#" + user.discriminator + "!");
}).build();
DiscordRPC.initialize("1234567890", handler, true);
}
Versions (Must be completed):
Additional info
Typo in readme
DiscordRPC.initialize() no longer exists in newest version
So I'm trying to log the user username + tag (given my the readme), but it's not running the callback and it's not making my profile show I'm playing something
public void check(Logger LOGGER)
{
LOGGER.info("Getting USER.");
DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler((user) -> {
LOGGER.info("Got USER.");
LOGGER.info("Welcome " + user.username + "#" + user.discriminator + "!");
}).build();
DiscordRPC.discordInitialize( client ID of the bot , handlers, true);
DiscordRPC.discordRegister( client ID of the bot , "");
}
public DiscordRichPresence createRPC(Logger LOGGER)
{
DiscordRichPresence rich = new DiscordRichPresence.Builder("This is the current state.").setDetails("These are some details.").build();
return rich;
}
public void updateRPC(Logger LOGGER, DiscordRichPresence rich)
{
DiscordRPC.discordRunCallbacks();
DiscordRPC.discordUpdatePresence(rich);
}
Each function is called from top to bottom, what am I doing wrong?
Edit*: I made the RP work, but the ".setReadyEventListener()" isn't work, here's the event code now (and I do have a thread that loops, and runs "DiscordRPC.discordRunCallbacks();"):
DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler(new ReadyCallback() {
@Override
public void apply(DiscordUser user) {
LOGGER.info("DiscordManager: Got user" + user.username + "#" + user.discriminator);
}
}).build();
Describe the bug
Source
Error
Versions (Must be completed):
Change this to the output of java -version
What version of discord-rpc are you using?
Additional info
---- Minecraft Crash Report ----
// You're mean.
Time: 3/5/22, 12:37 PM
Description: Initializing game
java.lang.NoClassDefFoundError: net/arikia/dev/drpc/callbacks/ReadyCallback
at Lucky.Client.(Client.java:10)
at Lucky.Client.(Client.java:5)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:470)
at net.minecraft.client.Minecraft.run(Minecraft.java:401)
at net.minecraft.client.main.Main.main(Main.java:113)
at Start.main(Start.java:11)
Caused by: java.lang.ClassNotFoundException: net.arikia.dev.drpc.callbacks.ReadyCallback
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 6 more
-- Head --
Stacktrace:
at Lucky.Client.(Client.java:10)
at Lucky.Client.(Client.java:5)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:470)
-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.run(Minecraft.java:401)
at net.minecraft.client.main.Main.main(Main.java:113)
at Start.main(Start.java:11)
-- System Details --
Details:
Minecraft Version: 1.8.8
Operating System: Windows 10 (amd64) version 10.0
CPU:
Java Version: 17.0.2, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode, sharing), Oracle Corporation
Memory: 868831744 bytes (828 MB) / 1073741824 bytes (1024 MB) up to 1073741824 bytes (1024 MB)
JVM Flags: 3 total; -XX:+ShowCodeDetailsInExceptionMessages -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
Launched Version: mcp
LWJGL: 2.9.4
OpenGL: ERROR RuntimeException: No OpenGL context found in the current thread.
GL Caps:
Using VBOs: ERROR NullPointerException: Cannot read field "useVbo" because "this.this$0.gameSettings" is null
Is Modded: Very likely; Jar signature invalidated
Type: Client (map_client.txt)
Resource Packs: ERROR NullPointerException: Cannot read field "resourcePacks" because "this.this$0.gameSettings" is null
Current Language: ERROR NullPointerException: Cannot invoke "net.minecraft.client.resources.LanguageManager.getCurrentLanguage()" because the return value of "net.minecraft.client.Minecraft.access$3(net.minecraft.client.Minecraft)" is null
Profiler Position: N/A (disabled)
CPU:
I keep getting a null pointer exception from the copyFile function
I don't really know what to do here.
this is my code
package me.neo.rpc;
import net.arikia.dev.drpc.DiscordEventHandlers;
import net.arikia.dev.drpc.DiscordRPC;
import net.arikia.dev.drpc.DiscordRichPresence;
import net.arikia.dev.drpc.DiscordUser;
import net.arikia.dev.drpc.callbacks.ReadyCallback;
import java.util.Date;
public class Discord {
private long time;
private String id;
public Discord(String id) {
System.out.println(System.mapLibraryName("discord-rpc"));
DiscordRichPresence.Builder rich = new DiscordRichPresence.Builder("Playing Minecraft");
DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler(new ReadyCallback() {
@Override
public void apply(DiscordUser user) {
System.out.printf("Discord: User %s%s has logged into Discord", user.username, user.discriminator);
time = new Date().getTime();
rich.setStartTimestamps(time);
rich.setDetails("Currently in the menu");
DiscordRPC.discordUpdatePresence(rich.build());
}
}).build();
this.id = id;
DiscordRPC.discordInitialize(this.id, handlers, false);
DiscordRPC.discordRegister(this.id, "");
new Thread(() -> {
while (true) {
DiscordRPC.discordRunCallbacks();
}
});
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
DiscordRPC.discordShutdown();
}));
}
}
After importing the library, when I try to run my app I get the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'discord-rpc': dlopen(libdiscord-rpc.dylib, 9): image not found at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163) at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236) at com.sun.jna.Library$Handler.<init>(Library.java:140) at com.sun.jna.Native.loadLibrary(Native.java:379) at com.sun.jna.Native.loadLibrary(Native.java:364) at net.arikia.dev.drpc.DiscordRPC$DLL.<clinit>(DiscordRPC.java:114) at net.arikia.dev.drpc.DiscordRPC.discordInitialize(DiscordRPC.java:33) at com.relic.sfs2x.Relic.init(Relic.java:65) at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.createExtension(SFSExtensionManager.java:303) at com.smartfoxserver.v2.entities.managers.SFSZoneManager.createRoom(SFSZoneManager.java:719) at com.smartfoxserver.v2.entities.managers.SFSZoneManager.createZone(SFSZoneManager.java:412) at com.smartfoxserver.v2.entities.managers.SFSZoneManager.initializeZones(SFSZoneManager.java:239) at com.smartfoxserver.v2.SmartFoxServer.start(SmartFoxServer.java:292) at com.smartfoxserver.v2.Main.main(Main.java:14)
I'm running 10.13.3 Beta. Is there another way I can include the rpc binaries? Nothing I try seems to behave.
Hello,
The library jar has windows 32bits dll in "win-x86" inside the jar. But line 120 in DiscordRPC.java it is looking for "win-x32" if the system is 32bits which gives an error.
Could you fix this?
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.