Giter Club home page Giter Club logo

java-discord-rpc's Issues

Maven repository

Hello, I am trying to find some Discord RPC library for Java right now, and only one I stumbled upon is also on Maven Repository. I would prefer to use this one, but as it is not on Maven Repository, it just complicates things.
Are there any plans to upload this library to Maven Repository?

Problem

Hi, I have a problem.
When I run the program, my window opens. But an error appears in the console :

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'discord-rpc': Native library (win32-x86-64/discord-rpc.dll) not found in resource path ([file:/C:/Program%20Files/Java/jre1.8.0_181/lib/resources.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/rt.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/jsse.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/jce.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/charsets.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/jfr.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/ext/access-bridge-64.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/ext/cldrdata.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/ext/dnsns.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/ext/jaccess.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/ext/jfxrt.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/ext/localedata.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/ext/nashorn.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/ext/sunec.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/ext/sunjce_provider.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/ext/sunmscapi.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/ext/sunpkcs11.jar, file:/C:/Program%20Files/Java/jre1.8.0_181/lib/ext/zipfs.jar, file:/C:/Users/Hugo/Desktop/Developpement/Java/WorkSpace/RichPresenceApp/bin/, file:/C:/Users/Hugo/Desktop/Developpement/Java/API/Discord/java-discord-rpc-2.0.1.jar, file:/C:/Users/Hugo/Desktop/Developpement/Java/API/Discord/jna-4.5.2.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 club.minnced.discord.rpc.DiscordRPC.<clinit>(DiscordRPC.java:42)
	at fr.hugogame18.richpresenceapp.MainRich.main(MainRich.java:18)

Code :

package fr.hugogame18.richpresenceapp;

import javax.swing.JFrame;

import club.minnced.discord.rpc.DiscordEventHandlers;
import club.minnced.discord.rpc.DiscordRPC;
import club.minnced.discord.rpc.DiscordRichPresence;

public class MainRich {

    public static Thread t;

    public static void main(String[] args) {

        JFrame fen = new FrameBot();

        DiscordRichPresence presence = new DiscordRichPresence();
        DiscordRPC lib = DiscordRPC.INSTANCE;
        String applicationId = "122";

        DiscordEventHandlers handlers = new DiscordEventHandlers();
        handlers.ready = (user) -> System.out.println("Ready!");

        lib.Discord_Initialize(applicationId, handlers, true, null);

        presence.startTimestamp = System.currentTimeMillis() / 1000; // epoch second
        presence.endTimestamp = presence.startTimestamp + 20;
        presence.details = "Details here";
        presence.state = "State here";
        presence.partySize = 1;
        presence.partyMax = 4;
        lib.Discord_UpdatePresence(presence);

        t = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                lib.Discord_RunCallbacks();
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    lib.Discord_Shutdown();
                    break;
                }
            }
        }, "RPC-Callback-Handler");
        t.start();

    }

}

Module not found

Sorry if this is a stupid question, but when I try to load it, it says that it cannot find the module "discord-rpc" and crashes. Any help would be greatly appreciated.

Issues with Unicode

I.e setting state to В главном меню results to this:
default
displayed in discord

Possible Extreme Bug

When I had called an UpdatePresence (DiscordRPC.INSTANCE.Discord_UpdatePresence) and then the shutdown (DiscordRPC.INSTANCE.Discord_Shutdown), it took me off my game for a split second and then re-put me on the game, which I can't now get off without re-launching the game. I don't know if this is a bug with Discord Rich Presence or DiscordRPC, but I thought I'd bring it to your attention.

Imposible to use it in a minecraft mod

Hi i'm trying to use your API to add discord RichPresence in my minecraft mod

When i put the code in my main class at the init process my package become incorect

here is my code

package fr.altisrp.mod;
// Error is HERE
import club.minnced.discord.rpc.*;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import fr.altisrp.mod.proxy.CommonProxy;

@Mod(modid = AltisRpMod.MODID, version = AltisRpMod.VERSION)
public class AltisRpMod
{
    public static final String MODID = "Altis_RP";
    public static final String VERSION = "0.0.1";
    
    @Instance("AltisRpMod")
    public static AltisRpMod instance;
   
    
    @SidedProxy(clientSide = "fr.altisrp.mod.proxy.ClientProxy", serverSide = "fr.altisrp.mod.proxy.CommonProxy")
    public static CommonProxy proxy;
    
    @EventHandler
    public void preinit(FMLPreInitializationEvent event)
    {
    	
		
		// some example code
        System.out.println("Pré init Altis Rp Mod");
  		 
  		
    }
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
    	
    	DiscordRPC lib = DiscordRPC.INSTANCE;
        String applicationId = "";
        String steamId = "";
        DiscordEventHandlers handlers = new DiscordEventHandlers();
        handlers.ready = (user) -> System.out.println("Ready!");
        lib.Discord_Initialize(applicationId, handlers, true, steamId);
        DiscordRichPresence presence = new DiscordRichPresence();
        presence.startTimestamp = System.currentTimeMillis() / 1000; // epoch second
        presence.details = "Starting Game";
        lib.Discord_UpdatePresence(presence);
        // in a worker thread
        new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                lib.Discord_RunCallbacks();
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException ignored) {}
            }
        }, "RPC-Callback-Handler").start();
		// some example code
        System.out.println("init Altis Rp Mod");
        proxy.registerRender();
        
		 
    }
    
    @EventHandler
    public void postInit(FMLPostInitializationEvent event)
    {
    	
    	
		// some example code
        System.out.println("PostInit Altis Rp Mod");
        
    }
}

eclipse says to configure build path . i dont knew what to do
Thanks for helping me

Deprecation of the official Discord SDK for RPC

Since discord has decided to deprecate the base library this depends on I can no longer continue support for it. The new SDK is not on github and doesn't really offer any good way to make similar bindings since the distribution doesn't offer the same range of platforms or documentation.
Fixing bugs myself in the SDK through pull requests seems out of the picture now.

Deprecation Notice

Error in LSRegisterURL: -10811

I use follow code

import club.minnced.discord.rpc.*;

public class Main {
    public static void main(String[] args) {
        DiscordRPC lib = DiscordRPC.INSTANCE;
        String applicationId = "";
        String steamId = "";
        DiscordEventHandlers handlers = new DiscordEventHandlers();
        handlers.ready = (user) -> System.out.println("Ready!");
        lib.Discord_Initialize(applicationId, handlers, true, steamId);
        DiscordRichPresence presence = new DiscordRichPresence();
        presence.startTimestamp = System.currentTimeMillis() / 1000; // epoch second
        presence.details = "Testing RPC";
        lib.Discord_UpdatePresence(presence);
        new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                lib.Discord_RunCallbacks();
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException ignored) {}
            }
        }, "RPC-Callback-Handler").start();
    }
}

and i get error in log
Error in LSRegisterURL: -10811

Unable to load library 'discord-rpc': The specified module could not be found.

Hello,

I'm trying to make a Minecraft mod that includes this library and I keep getting this error

Error: net.minecraftforge.fml.common.LoaderException: java.lang.UnsatisfiedLinkError: Unable to load library 'discord-rpc': The specified module could not be found.

Then in console I get this error:

// Hi. I'm Minecraft, and I'm a crashaholic.

Time: 28/08/18 11:20
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderException: java.lang.UnsatisfiedLinkError: Unable to load library 'discord-rpc': The specified module could not be found.

	at net.minecraftforge.fml.common.LoadController.transition(LoadController.java:162)
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:559)
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243)
	at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:417)
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:329)
	at net.minecraft.client.main.Main.main(SourceFile:124)
	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:497)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
Caused by: java.lang.UnsatisfiedLinkError: Unable to load library 'discord-rpc': The specified module could not be found.

	at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:169)
	at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:242)
	at com.sun.jna.Library$Handler.<init>(Library.java:140)
	at com.sun.jna.Native.loadLibrary(Native.java:368)
	at com.sun.jna.Native.loadLibrary(Native.java:353)
	at club.minnced.discord.rpc.DiscordRPC.<clinit>(DiscordRPC.java:42)
	at curiousclient.discord.DiscordRP.init(DiscordRP.java:11)
	at curiousclient.CuriousClient.preInit(CuriousClient.java:36)
	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:497)
	at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:560)
	at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
	at com.google.common.eventbus.EventBus.post(EventBus.java:275)
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:211)
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:189)
	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:497)
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
	at com.google.common.eventbus.EventBus.post(EventBus.java:275)
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:556)
	... 10 more

Anyone know what I'm doing wrong?

Thanks,
George

Handlers not being triggered

Hey,

So i already set up the presence etc everything works, but how do i catch an error/check if discord is even running?

Error in LSRegisterURL: -10811

whenever i try to start the discord rpc it gives me this error

Error in LSRegisterURL: -10811

does anyone know how to fix this?
(I'm on macos/darwin)

Can't find class definitions

When using javac -cp lib/<discord-rpc>.jar:. <main>.jar (obviously with the real names), the compilation has no issues and finishes just fine. However, when I try to run the app using java -cp <same classpath> <main>.class, it gives me:

Exception in thread "main" java.lang.NoClassDefFoundError: club/minnced/discord/rpc/DiscordRPC
	at mainGame.Game.<init>(Game.java:135)
	at mainGame.Game.main(Game.java:408)
Caused by: java.lang.ClassNotFoundException: club.minnced.discord.rpc.DiscordRPC
	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)
	... 2 more

Not sure why this is, since the compiler had no issue with it. If I switch the line with the one after it (instantiating my DiscordEventHandlers), it's the same error but with the DiscordEventHandlers class, so it's not limited only to DiscordRPC. Any clue what's wrong? 100% could be a user error, I don't do too much with external libs, so I might be doing something wrong.

Natives not found even tho they're in /src/main/resources

I've setup this project using Maven and it worked before but now it stopped detecting the natives, i've tried reinstalling them in the correct folder but it still gives an exception.

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:169)
	at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:242)
	at com.sun.jna.Library$Handler.<init>(Library.java:140)
	at com.sun.jna.Native.loadLibrary(Native.java:368)
	at com.sun.jna.Native.loadLibrary(Native.java:353)
	at club.minnced.discord.rpc.DiscordRPC.<clinit>(DiscordRPC.java:42)

About secret

how can I avoid my app to be used on other people's rpc?
they can get our client id in the browser

Can not share my presence

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

[Request/Help] Function to check if an Image Exists?

Hi :)

This isnt an issue really, but I'm just wondering for an App I'm working on, if there is a way to check to see if an image key is equal to a Large or Small Image or if there is no image with the specific image key.

C thread exception on termination of RPC

Was working on another example to add to the repo (more specifically I was porting Discord's send-presence.c example to Java) I ran into an issue where when the thread is interrupted to shut down the RPC connection, the library would give me a C++ error as follows:

libc++abi.dylib: terminating with uncaught exception of type std::__1::system_error: thread::join failed: Invalid argument

My code is available here, and unrelated I believe it would be ready for a pull request once this issue is resolved.

The peculiar thing is, I have identical code in my previous example code, yet I don't encounter this issue. The fact that it happens in some cases and not others is the reason why I'm submitting this issue to this repo and not the root Discord RPC repo. If it's found that the issue lies in the core C code, I'd be happy to report it to that repo as well. Of course, it's also entirely possible that I'm a dumbass and overlooked some code, in which case being pointed to and laughed at is entirely warranted. 😄

No message no error ...

hey!

i can't figure out the problem. using the first basic, no message no error. dll added to the project.

java.lang.UnsatisfiedLinkError: shadow.com.sun.jna.Native.getNativeVersion()Ljava/lang/String;

Caught exception from mcctfdiscordhook java.lang.UnsatisfiedLinkError: shadow.com.sun.jna.Native.getNativeVersion()Ljava/lang/String;
 	at shadow.com.sun.jna.Native.getNativeVersion(Native Method)
 	at shadow.com.sun.jna.Native.<clinit>(Native.java:192)
 	at shadow.club.minnced.discord.rpc.DiscordRPC.<clinit>(DiscordRPC.java:42)
 	at main.java.redsli.me.mcctfdiscordhook.runnables.DiscordPresenceUpdater.<init>(DiscordPresenceUpdater.java:21)

Line 21: lib = DiscordRPC.INSTANCE;

I'm shadowing the jar with this gradle plugin, not sure if relevant or not.

UnsatisfiedLinkError on release jar

I've downloaded and imported the library to my project (from the "Releases" page), and for some reason, whenever I run my code, it spits out a stacktrace error (UnsatisfiedLinkedError) that it can't load the library.

Java SDK version: 1.8.0_191
Images of the code, stacktrace errors etc.: https://imgur.com/a/9WgX5fq

Unable to load library 'discord-rpc' Minecraft 1.8.8 MCP Error

Hello, I have a problem, when i use the library in Minecraft MCP 1.8 (mcp910-pre1) that's work, but, if i want use it in Minecraft MCP 1.8.8 (MCP918), when minecraft start i have that's error:

---- Minecraft Crash Report ----
// Why is it breaking :(

Time: 02/05/19 21:30
Description: Initializing game

java.lang.UnsatisfiedLinkError: Unable to load library 'discord-rpc': Le module spécifié est introuvable.

at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:169)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:242)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:368)
at com.sun.jna.Native.loadLibrary(Native.java:353)
at club.minnced.discord.rpc.DiscordRPC.<clinit>(DiscordRPC.java:42)
at aroz.main.Discord.startDiscord(Discord.java:14)
at aroz.main.Client.startClient(Client.java:25)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:590)
at net.minecraft.client.Minecraft.run(Minecraft.java:400)
at net.minecraft.client.main.Main.main(Main.java:113)
at Start.main(Start.java:11)

A detailed walkthrough of the error, its code path and all known details is as follows:

-- Head --
Stacktrace:
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:169)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:242)
at com.sun.jna.Library$Handler.(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:368)
at com.sun.jna.Native.loadLibrary(Native.java:353)
at club.minnced.discord.rpc.DiscordRPC.(DiscordRPC.java:42)
at aroz.main.Discord.startDiscord(Discord.java:14)
at aroz.main.Client.startClient(Client.java:25)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:590)

-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.run(Minecraft.java:400)
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
Java Version: 1.8.0_201, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 920649504 bytes (877 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
Launched Version: mcp
LWJGL: 2.9.4
OpenGL: GeForce GTX 750 Ti/PCIe/SSE2 GL version 4.6.0 NVIDIA 419.35, NVIDIA Corporation
GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

Using VBOs: No
Is Modded: Very likely; Jar signature invalidated
Type: Client (map_client.txt)
Resource Packs: 
Current Language: English (US)
Profiler Position: N/A (disabled)
CPU: 8x Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz

#@!@# Game crashed! Crash report saved to: #@!@# C:\Users\mathe\Desktop\Aroz-CM\mods1.8.8\jars.\crash-reports\crash-2019-05-02_21.30.12-client.txt
[21:30:12] [Client Shutdown Thread/INFO]: Stopping server
AL lib: (EE) alc_cleanup: 1 device not closed
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release

You have any idea ? And sorry for my bad English, i'm french.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.