Discord rpc что это
This library has been deprecated in favor of Discord's GameSDK. Learn more here
This is a library for interfacing your game with a locally running Discord desktop client. It's known to work on Windows, macOS, and Linux. You can use the lib directly if you like, or use it as a guide to writing your own if it doesn't suit your game as is. PRs/feedback welcome if you have an improvement everyone might want, or can describe how this doesn't meet your needs.
Included here are some quick demos that implement the very minimal subset to show current status, and have callbacks for where a more complete game would do more things (joining, spectating, etc).
The most up to date documentation for Rich Presence can always be found on our developer site! If you're interested in rolling your own native implementation of Rich Presence via IPC sockets instead of using our SDK—hey, you've got free time, right?—check out the "Hard Mode" documentation.
Zeroith, you should be set up to build things because you are a game developer, right?
First, head on over to the Discord developers site and make yourself an app. Keep track of Client ID -- you'll need it here to pass to the init function.
Unreal Engine 4 Setup
To use the Rich Presense plugin with Unreal Engine Projects:
- Download the latest release for each operating system you are targeting and the zipped source code
- In the source code zip, copy the UE plugin— examples/unrealstatus/Plugins/discordrpc —to your project's plugin directory
- At [YOUR_UE_PROJECT]/Plugins/discordrpc/source/ThirdParty/DiscordRpcLibrary/ , create an Include folder and copy discord_rpc.h and discord_register.h to it from the zip
- Follow the steps below for each OS
- Build your UE4 project
- Launch the editor, and enable the Discord plugin.
- At [YOUR_UE_PROJECT]/Plugins/discordrpc/source/ThirdParty/DiscordRpcLibrary/ , create a Win64 folder
- Copy lib/discord-rpc.lib and bin/discord-rpc.dll from [RELEASE_ZIP]/win64-dynamic to the Win64 folder
- At [YOUR_UE_PROJECT]/Plugins/discordrpc/source/ThirdParty/DiscordRpcLibrary/ , create a Mac folder
- Copy libdiscord-rpc.dylib from [RELEASE_ZIP]/osx-dynamic/lib to the Mac folder
- At [YOUR_UE_PROJECT]/Plugins/discordrpc/source/ThirdParty/DiscordRpcLibrary/ , create a Linux folder
- Inside, create another folder x86_64-unknown-linux-gnu
- Copy libdiscord-rpc.so from [RELEASE_ZIP]/linux-dynamic/lib to Linux/x86_64-unknown-linux-gnu
If you're a Unity developer looking to integrate Rich Presence into your game, follow this simple guide to get started towards success:
- Download the DLLs for any platform that you need from our releases
- In your Unity project, create a Plugins folder inside your Assets folder if you don't already have one
- Copy the file DiscordRpc.cs from here into your Assets folder. This is basically your header file for the SDK
We've got our Plugins folder ready, so let's get platform-specific!
- Create x86 and x86_64 folders inside Assets/Plugins/
- Copy discord-rpc-win/win64-dynamic/bin/discord-rpc.dll to Assets/Plugins/x86_64/
- Copy discord-rpc-win/win32-dynamic/bin/discord-rpc.dll to Assets/Plugins/x86/
- Click on both DLLs and make sure they are targetting the correct architectures in the Unity editor properties pane
- Done!
- Copy discord-rpc-osx/osx-dynamic/lib/libdiscord-rpc.dylib to Assets/Plugins/
- Rename libdiscord-rpc.dylib to discord-rpc.bundle
- Done!
- Copy discord-rpc-linux/linux-dynamic-lib/libdiscord-rpc.so to Assets/Plugins/
- Done!
You're ready to roll! For code examples on how to interact with the SDK using the DiscordRpc.cs header file, check out our example
Download a release package for your platform(s) -- they have subdirs with various prebuilt options, select the one you need add /include to your compile includes, /lib to your linker paths, and link with discord-rpc . For the dynamically linked builds, you'll need to ship the associated file along with your game.
First-eth, you'll want CMake . There's a few different ways to install it on your system, and you should refer to their website. Many package managers provide ways of installing CMake as well.
To make sure it's installed correctly, type cmake --version into your flavor of terminal/cmd. If you get a response with a version number, you're good to go!
There's a CMake file that should be able to generate the lib for you; Sometimes I use it like this:
There is a wrapper build script build.py that runs cmake with a few different options.
Usually, I run build.py to get things started, then use the generated project files as I work on things. It does depend on click library, so do a quick pip install click to make sure you have it if you want to run build.py .
There are some CMake options you might care about:
flag | default | does |
---|---|---|
ENABLE_IO_THREAD | ON | When enabled, we start up a thread to do io processing, if disabled you should call Discord_UpdateConnection yourself. |
USE_STATIC_CRT | OFF | (Windows) Enable to statically link the CRT, avoiding requiring users install the redistributable package. (The prebuilt binaries enable this option) |
BUILD_SHARED_LIBS | OFF | Build library as a DLL |
WARNINGS_AS_ERRORS | OFF | When enabled, compiles with -Werror (on *nix platforms). |
Why do we have three of these? Three times the fun!
CI | badge |
---|---|
TravisCI | |
AppVeyor | |
Buildkite (internal) |
This is a text adventure "game" that inits/deinits the connection to Discord, and sends a presence update on each command.
This is a sample Unity project that wraps a DLL version of the library, and sends presence updates when you click on a button. Run python build.py unity in the root directory to build the correct library files and place them in their respective folders.
This is a sample Unreal project that wraps the DLL version of the library with an Unreal plugin, exposes a blueprint class for interacting with it, and uses that to make a very simple UI. Run python build.py unreal in the root directory to build the correct library files and place them in their respective folders.
Wrappers and Implementations
Below is a table of unofficial, community-developed wrappers for and implementations of Rich Presence in various languages. If you would like to have yours added, please make a pull request adding your repository to the table. The repository should include:
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Open with Desktop
- View raw
- Copy raw contents Copy raw contents
Copy raw contents
Copy raw contents
This library has been deprecated in favor of Discord's GameSDK. Learn more here
This is a library for interfacing your game with a locally running Discord desktop client. It's known to work on Windows, macOS, and Linux. You can use the lib directly if you like, or use it as a guide to writing your own if it doesn't suit your game as is. PRs/feedback welcome if you have an improvement everyone might want, or can describe how this doesn't meet your needs.
Included here are some quick demos that implement the very minimal subset to show current status, and have callbacks for where a more complete game would do more things (joining, spectating, etc).
The most up to date documentation for Rich Presence can always be found on our developer site! If you're interested in rolling your own native implementation of Rich Presence via IPC sockets instead of using our SDK—hey, you've got free time, right?—check out the "Hard Mode" documentation.
Zeroith, you should be set up to build things because you are a game developer, right?
First, head on over to the Discord developers site and make yourself an app. Keep track of Client ID -- you'll need it here to pass to the init function.
Unreal Engine 4 Setup
To use the Rich Presense plugin with Unreal Engine Projects:
- Download the latest release for each operating system you are targeting and the zipped source code
- In the source code zip, copy the UE plugin— examples/unrealstatus/Plugins/discordrpc —to your project's plugin directory
- At [YOUR_UE_PROJECT]/Plugins/discordrpc/source/ThirdParty/DiscordRpcLibrary/ , create an Include folder and copy discord_rpc.h and discord_register.h to it from the zip
- Follow the steps below for each OS
- Build your UE4 project
- Launch the editor, and enable the Discord plugin.
- At [YOUR_UE_PROJECT]/Plugins/discordrpc/source/ThirdParty/DiscordRpcLibrary/ , create a Win64 folder
- Copy lib/discord-rpc.lib and bin/discord-rpc.dll from [RELEASE_ZIP]/win64-dynamic to the Win64 folder
- At [YOUR_UE_PROJECT]/Plugins/discordrpc/source/ThirdParty/DiscordRpcLibrary/ , create a Mac folder
- Copy libdiscord-rpc.dylib from [RELEASE_ZIP]/osx-dynamic/lib to the Mac folder
- At [YOUR_UE_PROJECT]/Plugins/discordrpc/source/ThirdParty/DiscordRpcLibrary/ , create a Linux folder
- Inside, create another folder x86_64-unknown-linux-gnu
- Copy libdiscord-rpc.so from [RELEASE_ZIP]/linux-dynamic/lib to Linux/x86_64-unknown-linux-gnu
If you're a Unity developer looking to integrate Rich Presence into your game, follow this simple guide to get started towards success:
- Download the DLLs for any platform that you need from our releases
- In your Unity project, create a Plugins folder inside your Assets folder if you don't already have one
- Copy the file DiscordRpc.cs from here into your Assets folder. This is basically your header file for the SDK
We've got our Plugins folder ready, so let's get platform-specific!
- Create x86 and x86_64 folders inside Assets/Plugins/
- Copy discord-rpc-win/win64-dynamic/bin/discord-rpc.dll to Assets/Plugins/x86_64/
- Copy discord-rpc-win/win32-dynamic/bin/discord-rpc.dll to Assets/Plugins/x86/
- Click on both DLLs and make sure they are targetting the correct architectures in the Unity editor properties pane
- Done!
- Copy discord-rpc-osx/osx-dynamic/lib/libdiscord-rpc.dylib to Assets/Plugins/
- Rename libdiscord-rpc.dylib to discord-rpc.bundle
- Done!
- Copy discord-rpc-linux/linux-dynamic-lib/libdiscord-rpc.so to Assets/Plugins/
- Done!
You're ready to roll! For code examples on how to interact with the SDK using the DiscordRpc.cs header file, check out our example
Download a release package for your platform(s) -- they have subdirs with various prebuilt options, select the one you need add /include to your compile includes, /lib to your linker paths, and link with discord-rpc . For the dynamically linked builds, you'll need to ship the associated file along with your game.
First-eth, you'll want CMake . There's a few different ways to install it on your system, and you should refer to their website. Many package managers provide ways of installing CMake as well.
To make sure it's installed correctly, type cmake --version into your flavor of terminal/cmd. If you get a response with a version number, you're good to go!
There's a CMake file that should be able to generate the lib for you; Sometimes I use it like this:
There is a wrapper build script build.py that runs cmake with a few different options.
Usually, I run build.py to get things started, then use the generated project files as I work on things. It does depend on click library, so do a quick pip install click to make sure you have it if you want to run build.py .
There are some CMake options you might care about:
flag | default | does |
---|---|---|
ENABLE_IO_THREAD | ON | When enabled, we start up a thread to do io processing, if disabled you should call Discord_UpdateConnection yourself. |
USE_STATIC_CRT | OFF | (Windows) Enable to statically link the CRT, avoiding requiring users install the redistributable package. (The prebuilt binaries enable this option) |
BUILD_SHARED_LIBS | OFF | Build library as a DLL |
WARNINGS_AS_ERRORS | OFF | When enabled, compiles with -Werror (on *nix platforms). |
Why do we have three of these? Three times the fun!
CI | badge |
---|---|
TravisCI | |
AppVeyor | |
Buildkite (internal) |
This is a text adventure "game" that inits/deinits the connection to Discord, and sends a presence update on each command.
This is a sample Unity project that wraps a DLL version of the library, and sends presence updates when you click on a button. Run python build.py unity in the root directory to build the correct library files and place them in their respective folders.
This is a sample Unreal project that wraps the DLL version of the library with an Unreal plugin, exposes a blueprint class for interacting with it, and uses that to make a very simple UI. Run python build.py unreal in the root directory to build the correct library files and place them in their respective folders.
Wrappers and Implementations
Below is a table of unofficial, community-developed wrappers for and implementations of Rich Presence in various languages. If you would like to have yours added, please make a pull request adding your repository to the table. The repository should include:
Java Wrapper of the Discord-RPC Library for Discord Rich Presence.
Ever wanted to use the Discord Rich Presence API in a Java Application, but then realized that the native version is C++ only? Well, worry no more, because Vatuu's Discord RPC is here. A complete wrapper of all functions the native Dynamic Library contains.
Set 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!
The so-called Rich Presence contains the following fields for you to fill in:
- State: The general state the current play-session is in (Waiting, Playing, Watching some leaderboards, etc).
- Details: Details to the current play-session, like the location, or current score.
- Timestamps: Show how long the current game-session will go, or how long the player is already playing, up to you.
- Images: One big cubic, and one smaller round images with a custom tooltip text, to show some more details.
- Parties: Show the current size of parties or lobbies to indicate if the player is forever alone or not.
- Match/Join/Spectate: Some super secret Strings that are needed for joining and spectating a game. More to that below.
- Instance Int: If it's a game instance or not, as simple as that.
Using this wrapper is as simple as it can be, with barely any difference of the "original" API.
Download one of the releases or download the sources to build your own release. Then, simply add and include it in your project.
Currently supported OS include Windows x86 , Windows x64 and Unix x64 . OSX and macOS support is currently broken, although we're working hard on getting it to work again.
Initialize the Discord RPC when your Application starts up. The Library is mostly static, so there is no need to create an Instance. The DiscordRPC.discordInitialize(); method takes 3 arguments to start.
- Client ID is the ID of your Discord Application.
- Handler is an instance of a DiscordEventHandler-Object. Callbacks to HandlerClasses are registered in there.
- AutoRegister does not really matter right now and is always true .
- If your application is a Steam Application, the Initialize Methods takes another String of your Steam App ID.
The Event Handler contains instances of the classes that handle Callbacks of the DiscordRPC. These classes have to implement the appropriate Interface for the Callback. The Callback-Interfaces are the following:
- DisconnectedCallback
- ErroredCallback
- JoinGameCallback
- JoinRequestCallback
- ReadyCallback
- SpectateGameCallback
To register a Callback, simply follow the following code:
All Callbacks are optional. You only need to register Classes that implement the Callbacks you need, or if you don't need any, simply pass an empty DiscordEventHandler Object.
To allow callbacks to be fired, you have to periodically call the method DiscordRPC.discordRunCallbacks(); . Otherwise, no callbacks will be passed to the application.
Congratulations, your Application is ready to utilize the Rich Presence.
Updating the Presence
To update the Rich Presence of a player, a DiscordRichPresence Object is required. There are created in the same way as the EventHandler is created, by using a Builder:
After the Object has been created, it simply has to be passed to the DiscordRPC with the methods DiscordRPC.discordUpdatePresence(DiscordRichPresence);
After calling that method, the presence of the player will have updated, according to the information passed. Just like the EventHandler before, 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 utilizing the Join and Spectate features.
More information regarding the fields of the Rich Presence and the correct usage of them can be found HERE.
Shutting down the RPC
To allow the IOStream utilized by the RPC to close properly, the method DiscordRPC.discordShutdown(); should always be called on exit of your application, otherwise issues might occure.
Joining and Spectating
The method DiscordRPC.discordRespond(String userId, DiscordReply reply); handles the reply on a JoinRequest by a player. When 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 the avatar of that user transformed into a SHA-1 hash.
Important Note: To let a application use the Spectate Feature, the application has to be greenlit by the Discord Developers. Otherwise, only certain users added to the Application will be able to use these features.
For further information regarding joining, spectating and getting greenlit, please visit THIS PAGE.
~~ More will be added soon ~~
The Example Application
Contained in this repository is a .JAR file called RPCTest.jar . This simple command line application can be used to test the Rich Presence for 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.
The RPCTest has only two commands:
- test will increase the "score" value in the details of your presence.
- shutdown is self-explanatory.
More questions? I recommend checking the official Discord Developer Docs.
Simple Discord RPC показывает ваш статус в discord. Умеет показывать что именно вы делаете в игре, на каком сервере играете, в каком биоме или на каких координатах. В отличии от Simple Discord Rich Presence не требует настройки и сложных махинаций для работы. Он выполняет все свои функции сразу после установки, но делает это на английском. Сейчас я расскажу как его перевести и настроить по вкусу:
Все настройки мода находятся в файле "simple-rpc.json", который расположен в папке .minecraft/config.
В нём всё разделено на блоки: main_menu, server_list и т.д. Для каждого блока подписи можно настроить отдельно, или вовсе отключить конкретный блок (под названием блока в строке "enabled" меняем "true" на "false").
На скриншоте выделен блок подписей когда игрок в одиночной игре
теперь по пунктам:
Остальные пункты я не затрагивал, и не знаю зачем именно они надо.
Не спешите в блокнот, ведь если вы просто измените всё в блокноте, то вместо букв вы увидите это:
Для того чтобы мод понял что вы ввели русские буквы, надо изменить кодировку конфиг-файла на UTF-8. Я знаю лишь один метод менять кодировку - программа Notepad++. Но в моём конфиг-файле кодировка уже заменена, так что сможете редактировать его блокнотом. А вообще в Notepad++ это делается так:
Не забудьте сохранить файл чтобы значок возле имени стал синим:
Также в файле можно заметить %такое%. Это сменные, которые заменяются словами в соответствии с вашей игрой:
%player% - Ваш ник в игре
%mcver% - Версия вашей игры
%mods% - Количество установленных модов
%world% - Измерение, в котором вы находитесь (из коробки поддерживает только три ванильные измерения, однако можно добавлять и свои из модов). Внизу есть большой блок "worlds", там вся информация об измерениях.
%difficulty% - сложность в игре
%position% - координаты игрока
%biome% - показывает текущий биом (например Taiga, Plains, Desert и т.д.)
%servername% - название сервера, на котором вы играете
%ip% - айпи адрес сервера, на котором вы играете
%players% - количество игроков на сервере (не включая вас)
Думаю, на этом гайд можно закончить. Если вам лень это делать и вы просто хотите готовый перевод, то внизу скачайте simple-rpc.json и поместите его в .minecraft/config (с заменой если мод уже был загружен).
To do: This implementation is fairly basic, so any edits or additions are greatly appreciated!
Implementing Discord RPC into the Source engine is simple, and it makes your mod stand out more, as your in-game "presence" can be seen through Discord.
Conclusion
The installation and setup are both complete! Try launching your mod and check your Discord status, now load up a map and check again!
This implementation works on Source SDK 2013 (SP/MP), as well as Source SDK 2007 (thanks to the IOSoccer team for testing!).
What is Discord RPC?
Discord RPC is a library for interfacing your game with a locally running Discord desktop client. It's known to work on Windows, macOS, and Linux. You can use the lib directly if you like, or use it as a guide to writing your own if it doesn't suit your game as is.
Below is an example using this article as a base, with obvious modifications:
Contents
The Installation
First off you'll need to download the latest version Discord RPC. You can do so by going to Discord's GitHub repository here. And download the latest discord-rpc-win.zip file, as of writing we'll be using v3.3.0. Once downloaded, open the archive and go to win32-dynamic/lib/ and extract discord-rpc.lib to your mod's /src/lib/public/ once that's done we'll do the same for the include files, in your archive take a step back and go into the include folder, now extract discord_rpc.h and discord_register.h to /src/public/. Now for the final step, once again in your archive take a step back and go into the bin folder, now extract discord-rpc.dll to your mod's /bin folder ex. /steamapps/sourcemods/YourMod/bin/.
The Setup
Now that the installation is done, it's time to set up our system. There's not a whole lot to do here, but this is a necessary step you'll have to take to make the implementation work.
To start off, go into /src/vpc_scripts/ and open source_dll_win32_base.vpc with your favorite text editor (I personally use Notepad++). Once you've opened the file, scroll all the way down to $Folder "Link Libraries" and under $Implib "$LIBPUBLIC\vstdlib" add $Lib "$LIBPUBLIC\discord-rpc" . After you've modified the VPC scripts, make sure to rerun createallprojects.bat and/or creategameprojects.bat before continuing, otherwise you might experience errors while building.
where the numbers after cl_discord_appid is your application's RPC AppID, to set up a RPC client go here, once your application is set up the number you'll want to place after cl_discord_appid is the "Client ID" seen in "General Information".
When that's done add the following above CHLClient::CHLClient()
Now scroll down to CHLClient::Init( . ) and add the following above return true; at the bottom of the function.
"ModImageHere" is an image key, remember that Discord developer page you were on earlier, where you set up your application? Go back there and to your application page, now go down to "Rich Presence" and click on "Art Assets" and click "Add Image(s)". Add an image you want for your mod and whatever you name that image is the name you replace "ModImageHere" with.
Now go further down to CHLClient::LevelInitPreEntity( . ) and above the comment for g_RagdollLVManager.SetLowViolence( pMapName ); add
Now we'll add the last piece of code into CHLClient::LevelShutdown( void ) . Below
Читайте также: