{"id":13467070,"url":"https://github.com/Vatuu/discord-rpc","last_synced_at":"2025-03-26T00:31:58.662Z","repository":{"id":48461727,"uuid":"111019025","full_name":"Vatuu/discord-rpc","owner":"Vatuu","description":"Java Wrapper of the Discord-RPC Library for Discord Rich Presence.","archived":true,"fork":false,"pushed_at":"2023-04-09T00:14:47.000Z","size":2750,"stargazers_count":192,"open_issues_count":11,"forks_count":42,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-29T20:34:51.458Z","etag":null,"topics":["discord","discord-rpc","discordrichpresence","java","java-wrapper","presence","rich","rich-presence","wrapper"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Vatuu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-16T20:31:09.000Z","updated_at":"2024-10-19T10:47:57.000Z","dependencies_parsed_at":"2024-10-29T19:54:15.395Z","dependency_job_id":null,"html_url":"https://github.com/Vatuu/discord-rpc","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vatuu%2Fdiscord-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vatuu%2Fdiscord-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vatuu%2Fdiscord-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vatuu%2Fdiscord-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vatuu","download_url":"https://codeload.github.com/Vatuu/discord-rpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245566099,"owners_count":20636391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["discord","discord-rpc","discordrichpresence","java","java-wrapper","presence","rich","rich-presence","wrapper"],"created_at":"2024-07-31T15:00:52.806Z","updated_at":"2025-03-26T00:31:58.657Z","avatar_url":"https://github.com/Vatuu.png","language":"Java","funding_links":["https://www.paypal.me/NicolasAdamoglou"],"categories":["Game SDK \u0026 RPC Bindings"],"sub_categories":[],"readme":"# Important Notice\n\nThis project is discontinued and will no longer be maintained as the DiscordRPC has been deprecated.\nIt has been replaced by the GameSDK which has wrappers maintained by people unrelated to this project.\nPlease stop using this library, and refrain from creating issues or PRs as they will likely not be resolved or merged.\n\n\u003cimg src=\"https://raw.githubusercontent.com/vatuu/discord-rpc/master/rpc.png\" align=\"right\" height=\"256\" width=\"256\"/\u003e\n\n[![jitpack](https://jitpack.io/v/Vatuu/discord-rpc.svg)](https://jitpack.io/#Vatuu/discord-rpc) [![Build Status](https://travis-ci.org/Vatuu/discord-rpc.svg?branch=master)](https://travis-ci.org/Vatuu/discord-rpc) \n\n# discord-rpc\nJava Wrapper of the Discord-RPC Library for Discord Rich Presence.\n\nEver wanted to use the Discord Rich Presence API in a Java Application, but then realized that the native version is C++ only?\nWell, worry no more, because Vatuu's Discord RPC is here. A complete wrapper of all functions the native Dynamic Library contains.\n\n## Features\nSet advanced pieces of information about your game in the players' profile, when they use your Application, from text to images, timers and even giving the option of joining/spectating a game!\n\nThe so-called Rich Presence contains the following fields for you to fill in:\n\n- State: The general state the current play-session is in (Waiting, Playing, Watching some leaderboards, etc).\n- Details: Details to the current play-session, like the location, or current score.\n- Timestamps: Show how long the current game-session will go, or how long the player is already playing, up to you.\n- Images: One big cubic, and one smaller round images with a custom tooltip text, to show some more details.\n- Parties: Show the current size of parties or lobbies to indicate if the player is forever alone or not.\n- Match/Join/Spectate: Some super secret Strings that are needed for joining and spectating a game. More to that below.\n- Instance Int: If it's a game instance or not, as simple as that.\n\n## How to use?\nUsing this wrapper is as simple as it can be, with barely any difference of the \"original\" API.\n\n### Step 0\n  Download one of the releases or download the sources to build your own release. Then, simply add and include it in your project.\n  \n  Currently supported OS include ``Windows x86``, ``Windows x64`` and ``Unix x64``. OSX and macOS support is currently broken,\n  although we're working hard on getting it to work again.\n\n### Step 1\nInitialize the Discord RPC when your Application starts up. The Library is mostly static, so there is no need to create an Instance.\nThe ``DiscordRPC.discordInitialize();`` method takes 3 arguments to start.\n- ``Client ID`` is the ID of your Discord Application.\n- ``Handler`` is an instance of a DiscordEventHandler-Object. Callbacks to HandlerClasses are registered in there.\n- ``AutoRegister``does not really matter right now and is always ``true``.\n- If your application is a Steam Application, the Initialize Methods takes another String of your Steam App ID.\n  \nThe Event Handler contains instances of the classes that handle Callbacks of the DiscordRPC. These classes have to implement\nthe appropriate Interface for the Callback. The Callback-Interfaces are the following:\n- ``DisconnectedCallback``\n- ``ErroredCallback``\n- ``JoinGameCallback``\n- ``JoinRequestCallback``\n- ``ReadyCallback``\n- ``SpectateGameCallback``\n  \nTo register a Callback, simply follow the following code:\n```java\npublic static class ReadyEvent implements ReadyCallback {\n  public void apply() {\n    System.out.println(\"Discord's ready!\");\n  }\n}\n  \npublic class MainClass {\n  public void startup() {\n    DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler((user) -\u003e {\n        System.out.println(\"Welcome \" + user.username + \"#\" + user.discriminator + \"!\");\n    }).build();\n  }\n}\n```\n  \n*All Callbacks are optional. You only need to register Classes that implement the Callbacks you need, or if you don't need any,\nsimply pass an empty DiscordEventHandler Object.*\n  \nTo summarize:\n```java \npublic void startup() {\n  DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler((user) -\u003e {\n      System.out.println(\"Welcome \" + user.username + \"#\" + user.discriminator + \"!\");\n  }).build();\n  DiscordRPC.discordInitialize(\"1234567890\", handlers, true);\n}\n```\n  \nThis would result in the message \"Welcome User#1234!\" being printed out in the console after the connection to Discord has been established, and fitted with the users username and discriminator.\n  \n### Step 2\nTo allow callbacks to be fired, you have to periodically call the method ``DiscordRPC.discordRunCallbacks();``. Otherwise, no callbacks will be passed\nto the application.\n  \n**Congratulations, your Application is ready to utilize the Rich Presence.**\n \n## Updating the Presence\n \nTo update the Rich Presence of a player, a ``DiscordRichPresence`` Object is required. There are created in the same way as the\nEventHandler is created, by using a Builder:\n```java\npublic void createNewPresence() {\n  DiscordRichPresence rich = new DiscordRichPresence.Builder(\"This is the current state.\").setDetails(\"These are some details.\").build();\n}\n```\nAfter the Object has been created, it simply has to be passed to the DiscordRPC with the methods ``DiscordRPC.discordUpdatePresence(DiscordRichPresence);``\n\n```java\npublic void createNewPresence() {\n  DiscordRichPresence rich = new DiscordRichPresence.Builder(\"This is the current state.\").setDetails(\"These are some details.\").build();\n  DiscordRPC.discordUpdatePresence(rich);\n}\n```\n\nAfter calling that method, the presence of the player will have updated, according to the information passed. Just like the EventHandler\nbefore, all fields are optional and can be left empty if one desires so. Just keep in mind that a Match- Join- and Spectate Secret are needed when\nutilizing the Join and Spectate features. \n\nMore information regarding the fields of the Rich Presence and the correct usage of them can be found [HERE](https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence \"Discord Developer Docs\").\n\n## Shutting down the RPC\nTo allow the IOStream utilized by the RPC to close properly, the method ``DiscordRPC.discordShutdown();`` should **always** be called on\nexit of your application, otherwise issues might occure.\n\n## Joining and Spectating\nThe method ``DiscordRPC.discordRespond(String userId, DiscordReply reply);`` handles the reply on a JoinRequest by a player.\nWhen a player requests to join a game, the ``JoinRequestCallback`` is called, which should be used to process the request. That request contains the Username, UserID and\nthe avatar of that user transformed into a SHA-1 hash.\n\n***Important Note:*** **To let a application use the Spectate Feature, the application has to be greenlit by the Discord Developers.\nOtherwise, only certain users added to the Application will be able to use these features.**\n\nFor further information regarding joining, spectating and getting greenlit, please visit [THIS PAGE](https://discordapp.com/developers/docs/rich-presence/how-to#joining \"Discord Developer Docs\").\n\n~~ *More will be added soon* ~~\n\n## The Example Application\nContained in this repository is a .JAR file called ``RPCTest.jar``. This simple command line application can be used to test the Rich Presence\nfor yourself! Simply add the Application named \"RPCTest\" to your Discord Games, and it will be recognized. Since Discord only detects games that have an active window, I discourage you from closing the small window called \"Derp\" that will pop up as soon as you start the RPCTest.\n\nThe RPCTest has only two commands:\n  - ``test`` will increase the \"score\" value in the details of your presence.\n  - ``shutdown`` is self-explanatory.\n \n -----------------------------------------------------------------------------------------------------------------------------------------------------------------\n More questions? I recommend checking the official [Discord Developer Docs](https://discordapp.com/developers/docs/rich-presence/ \"Discord Developer Docs\").\n \n **Best regards,**\nVatuu   \n\n[![Donate](https://img.shields.io/badge/Donate-PayPal-7289DA.svg)](https://www.paypal.me/NicolasAdamoglou)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVatuu%2Fdiscord-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FVatuu%2Fdiscord-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVatuu%2Fdiscord-rpc/lists"}