How to use Discord Rich Presence in Unreal Engine 4

Many modern games are adopting Discord’s Rich Presence features to display stats about your current game session to friends.

In this guide we will be working through how to use Discord Rich Presence in Unreal Engine 4 by downloading, installing and implementing Discord RPC and Rich Presence into your Unreal Engine 4 project.

discord logo

Discord has released their newer GameSDK which runs entirely using either C# for Unity or C++ for Unreal Engine. GameSDK is beyond the scope for this difficulty level which is why we will be using Discord RPC.

Adding the Discord Plugin

Downloading the Discord Plugin

Many features for Unreal Engine are built into the engine using C++ and others are compiled into a plugin. Discord has already prepared a ready made plugin for use with Unreal Engine on their GitHub page.

Method 1:

Click here to download the Discord RPC master zip.
This file is hosted on the official Discord GitHub page and not CouchLearn.com

After downloading, unzip the discord-rpc-master.zip file somewhere you can easily access it.

Method 2:

If you would like to manually clone the repository yourself click here to visit Discord’s GitHub page.

discord official GitHub page

Library Files

To download the library files necessary for compilation later on navigate to the releases section of the DiscordRPC GitHub page.

Click here to view the Releases

This file is hosted on the official Discord GitHub page and not CouchLearn.com

Find the latest release (Green text on the left) and download the discord-rpc-win.zip file.

Discord library file download

Unzip the discord-rpc-win.zip file somewhere you can easily access it.

Installing the Discord Plugin

Copying the Plugin

In our project folder we need to make sure there is a Plugins folder.

Create a new folder in your project folder named Plugins.

If you already have this you can move onto the next step.

creating the plugins folder

Included in the extracted discord RPC master folder is an example project for Unreal Engine 4.

This project has a pre-compiled Discord plugin ready for your project.

To find this plugin navigate to examples:

Discord rich presence examples from GitHub

Next, navigate to the unrealstatus folder:

Unreal Engine 4 discord example project

Finally, navigate to the Plugins folder:

Plugins folder of the Discord Rich Presence Unreal Engine 4 example project

Inside the Plugins folder is a folder named discordrpc. We need to copy and paste this folder into our own project’s Plugins folder created earlier.

The folder to copy

After copying and pasting the discordrpc folder, our project’s Plugins folder now looks like this:

DiscordRPC folder copied to your project.

Copying files to Compile the plugin

In the discord-rpc-master folder copy the include folder.

Finding the include folder and copying it

Navigate to the /ThirdParty/DiscordRpcLibrary folder in your project’s plugins folder and paste the include folder.

Pasting into the Library folder

Rename this folder to Include (make sure it has a capital I).

Renaming the include folder to Include

Create a new folder named Win64:

Creating the Win64 folder

Navigate to the /win64-dynamic/lib folder then copy and paste the discord-rpc.lib file into the Win64 folder created in the last step.

Copying the .lib file

Navigate to the /win64-dynamic/bin folder then copy and paste the discord-rpc.dll file into the Win64 folder.

copying the .dll file

Once completed your Win64 folder will look like this:

The final Win64 folder

To add Mac support for Discord to your Game click the link here for our guide for Compiling and Packaging Discord on Mac OSX.

To add Linux support for Discord to your Game click the link here for our guide for Compiling and Packaging Discord on Linux.

Compiling the Plugin

The plugin is made ready but your project doesn’t know that the files are there and hasn’t created its own files in preparation. This is why we compile the plugin on the first launch.

To compile the plugin, firstly launch your project.

As your new plugin hasn’t been compiled for your project this new prompt will show.

Press Yes to compile the plugin for your project:

Compiling the DiscordRpc plugin

The compile window will show and display the progress. This process takes a few minutes upto 10 minutes depending on the size of your project.

Unreal Engine 4 progress bar building the plugin

Enabling the Discord Plugin

Once the editor has launched, navigate to the plugins section and scroll to the bottom.

In the messaging section make sure the Discord RPC plugin is enabled.

Final plugin in the engine

If this plugin wasn’t enabled make sure to reload your editor after enabling it.

Using Discord in your Blueprints

Creating the Discord Object

In your Game Instance create a new variable named DiscordInstance and set its type to DiscordRPC object reference.

Creating the DiscordRPC object variable.

In your level blueprint, on the Begin Play event, create a Construct Object from Class node.

Constructing the discord rpc object class

For the Class node select the DiscordRpc class.

Setting the construct to the DiscordRPC object class

The outer pin is the owner of the DiscordRPC object. This should be set to your Game Instance.

Setting the outer (owner) to the game instance

Create a Cast node to your Game Instance.

Casting to the game instance

Set the DiscordInstance variable from your Game Instance to the return value of the Construct Discord RPC node.

Setting the discord instance variable to the constructed DiscordRpc class

Initializing the Connection

The Discord client needs to be notified to recieve any Rich Presence information. To notify the client, firstly create an Initialize Connection node.

Initializing the connection to discord

In the Application Id pin, copy and paste your client id from the Discord Developer Portal.

Retrieving the Client ID
Setting the Client ID into the game

Setting Discord Presence Information

Before sending the rich presence information to Discord, we need to set the variable containing the message that will be sent.

To set this create a Set Rich Presence Info node from the Discord Instance variable.

Setting the rich presence information

Right clicking and clicking break pin on the input pin of the new Set Rich Presence Info will show all the possible settings.

With this node created the entire Rich Presence data can now be set.

Full list of rich presence information

Formatting

The formatting is very specific as certain strings in the Set Rich Presence Info node are used for the Discord UI elements.

Below is the formatting from the Discord Developer page on Rich Presence.

Discord Rich Presence formatting
Image Credit: https://discordapp.com/developers/docs/rich-presence/how-to

Complete the Rich Presence information in the Set Rich Presence Info node with the formatting above.

Setting up the Timestamp (Advanced)

If your game needs to show the duration of play, follow this next section to setup the timestamp.

Discord uses the UNIX epoch system for time. Unreal Engine 4 has no built in blueprint nodes for getting the UNIX epoch time so we will have to create a few nodes to compensate for this.

Create the blueprint nodes below and connect the truncate return value to the start timestamp to count up showing duration of play since starting the game.

Creating the correct UNIX epoch timestamp

Using Images

To add an image to your Discord App, go to the Discord Developer Portal and in the Rich Presence art assets section upload the images your game requires.

Uploading images to the Discord Developer Portal

The uploaded file’s name is the key name used for the Set Rich Presence Info node. I used the Unreal Engine logo and the key is ue4logo shown above.

Adding the image key to the game

Sending information to the Discord Client

To send the rich presence information simply create a Send Presence node from the DiscordInstance variable as the target. Once you load your level the discord information will appear.

The complete Rich Presence information being sent

Here’s the final result using the settings above:

The rich presence data from the Discord client showing in game data
Label showing the discord app project name

Conclusion

Your game now has full use of Discord’s Rich Presence system in Unreal Engine 4!

Setting the presence data based on current level or your characters situation can then be used to update the client based on their current session. Just make sure to send the presence data once you have set it!

This is my largest and most comprehensive guide yet. If you found this helpful, please share with friends, other developers or on social media as more guides are coming soon.

If you want a specific guide, more guides of a specific difficulty or even different engine guides contact CouchLearn using the Contact Us link at the top of the site.

For more information on Discord Rich Presence system, click here for the full documentation.

Share your thoughts

48 Replies to “How to use Discord Rich Presence in Unreal Engine 4”

  1. I keep getting the message saying that it could not be compiled I double checked just in case I messed anything up. UE 4.24.3

    1. If you could send a screenshot of the compilation errors that you are having that would be great for solving this issue together.

      1. thank for your reply, it works but when i pack my project it tells me that the “ModuleManager.h” is missing.
        Do you have a solution ?

        1. You will need to modify the plugin that is causing the error and include the module manager header file.

          This is the code needed:
          #include “Modules/ModuleManager.h”

          1. Thanks for your reply. I have the same problem with the “IPluginManager”. I try to make this : #include “Modules/IPluginManager.h” but that doesen’t work. Do you have the solution ?

          2. Usually these includes are needed:

            #include “SlateBasics.h”

            #include “SlateExtras.h”

            I hope this helps!

  2. Thank you very much for the time you have given to answer my questions. By changing what you told me a few lines of code need to be changed. I tried for myself with a little logic but it does not work. I am sending you a screenshot of the packaging of the error: https://ibb.co/XVRgLQd
    ( I’m french so the text say : “is not a class name or namespace” “identifier not found” and “Impossible d’ouvrir le fichier include”)
    Thanks

      1. Try removing these lines:
        #include “SlateBasics.h”
        #include “SlateExtras.h”

        And adding this one:
        #include “Interfaces/IPluginManager.h”

        1. ok thanks this problem is solved !
          There is more than one problem to solve:
          the #include “discord_rpc.h” doesn’t works in the DiscordRcpBluprint.cpp

          1. Is the discord_rpc.h file in the discordrpc\Source\ThirdParty\DiscordRpcLibrary\Include folder?

    1. From the discord-rpc-master zip downloaded from the Discord RPC github, copy the discord_rpc.h file from the include folder and paste it into the Plugins/discordrpc\Source\ThirdParty\DiscordRpcLibrary\Include folder of your Unreal Engine project.

      This should solve the problem.

        1. Unresolved symbol errors like that usually are due to files, libraries or dlls not being found. Are you sure you followed the tutorial carefully and placed the files in the right places? Any missing or misplaced files will cause this plugin to not work correctly.

          1. Ok I redo all and that works ! Tanks you so much ! Now when i play my game in the editor that works but when i package and I play Discord doesn’t works… Why ?

  3. I already package on Windows x64. When I read the log there is no error or warning. it’s works perfectely when I play on the editor. I don’t undertand…

      1. The in-game events are working. Because in the editor everything works. Do you need something else to let it work outside the editor, so when the project has been exported??

        1. If you have followed the guide exactly it should work both in the editor and in a packaged build. Are you packaging a development build or a shipping build? Does the discordrpc folder exist in the packaged game plugin folder?

          1. Yes he exist. I don’t know if it’s normal but some files are missing in it. Should it be initialized at a specific place or time?

          2. Try packaging a development build and using print strings to see if the constructed discord object is valid and can be accessed.

          3. Check the logs from your development build game and see if discord is throwing any errors. These errors will show what exactly isn’t working with the plugin in the built game.

  4. I don’t know if it can help but when I “launch” my project in the editor I come across this error: “Error: Circular dependency detected for filename C: \ Users \ MyName \ Documents \ Unreal Projects \ MyProject \ Plugins \ discordrpc \ Source \ DiscordRpc \ Public \ DiscordRpcBlueprint.h! ” and oddly it does not work …

    1. That’s most likely the issue. A circular dependency would prevent the plugin from compiling when packaging your project. Replace the files that have errors and try packaging again.

      1. I would love to do it but I don’t know anything about C ++ and I can’t even find out where the error came from …

        1. Check to see if C:\Users\MyName\Documents\Unreal Projects\MyProject\Plugins\discordrpc\Source\DiscordRpc\Public\DiscordRpcBlueprint.h! has #include DiscordRpcBlueprint.h tn the code.

          If this line is inside the file it is calling itself which is a circular dependency.

          Try to replace the DiscordRpcBlueprint.h file with the default one from the DiscordRPC github download.

          Learning the basics of C++ will really improve your programming ability and concepts so I recommend this site if you have the time: http://www.cplusplus.com/doc/tutorial/

          1. Hello, sorry for the late reply. By replacing “DiscordRpcPlugin.h” with the one in the default project … and it is not very conclusive. I’m getting lots of errors and I hope they will be resolved very quickly. ( https://ibb.co/7Nk8vcf ) It really damages the plugin has lots of potential but it is not usable at the moment.

  5. OK it works! Now when I build my game I get a warning: “Warning: Accessed None trying to read property Discord”
    How to solve it ?

    1. Could you send a screenshot of the blueprints that are causing this error?

      It’s most likely that you aren’t storing or accessing the constructed Discord object in the variable correctly.

      1. It’s good it works thank you very much for your patience if you are the owner of the Github project it would be nice to update it to avoid other people from not being able to use the plugin. The plugin is very easy to use, however I would really like to exploit the full potential of this plugin and I would like my friends to be able to join me (of course my game is for multiplayer and I therefore created sessions) but I may specify the “Party ID” but I’m not sure what to put in the fields “Join Secret” and “Spectate Secret” as well as the box “Instance”. Can you enlighten me?
        Thanks

  6. So when i try to package my game i get this error any way to fix?
    LogUObjectHash: Compacting FUObjectHashTables data took 2.29ms
    LogMainFrame: Project does not require temp target
    LogLauncherProfile: Unable to use promoted target – ../../../Engine/Binaries/Win64/BadGame-Win64-Shipping.target does not exist.
    UATHelper: Packaging (Windows (64-bit)): Running AutomationTool…
    UATHelper: Packaging (Windows (64-bit)): Parsing command line: -ScriptsForProject=D:/BadGame/BadGame.uproject BuildCookRun -nocompileeditor -installed -nop4 -project=D:/BadGame/BadGame.uproject -cook -stage -archive -archivedirectory=C:/Users/Jacobb626YT/Documents -package -ue4exe=D:\Games\UE_4.25\Engine\Binaries\Win64\UE4Editor-Cmd.exe -pak -prereqs -nodebu
    ginfo -manifests -targetplatform=Win64 -build -target=BadGame -clientconfig=Shipping -utf8output
    UATHelper: Packaging (Windows (64-bit)): Setting up ProjectParams for D:\BadGame\BadGame.uproject
    UATHelper: Packaging (Windows (64-bit)): ********** BUILD COMMAND STARTED **********
    UATHelper: Packaging (Windows (64-bit)): Running: D:\Games\UE_4.25\Engine\Binaries\DotNET\UnrealBuildTool.exe BadGame Win64 Shipping -Project=D:\BadGame\BadGame.uproject D:\BadGame\BadGame.uproject -NoUBTMakefiles -remoteini=”D:\BadGame” -skipdeploy -Manifest=D:\BadGame\Intermediate\Build\Manifest.xml -NoHotReload -log=”C:\Users\Jacobb626YT\AppData\Roaming
    \Unreal Engine\AutomationTool\Logs\D+Games+UE_4.25\UBT-BadGame-Win64-Shipping.txt”
    UATHelper: Packaging (Windows (64-bit)): Using ‘git status’ to determine working set for adaptive non-unity build (D:\BadGame).
    UATHelper: Packaging (Windows (64-bit)): D:\BadGame\Plugins\discordrpc\Source\DiscordRpc\DiscordRpc.Build.cs: warning: Referenced directory ‘D:\BadGame\Plugins\discordrpc\Source\BadGame\Plugins\discordrpc\Source\DiscordRpc\Private’ does not exist.
    PackagingResults: Warning: Referenced directory ‘D:\BadGame\Plugins\discordrpc\Source\BadGame\Plugins\discordrpc\Source\DiscordRpc\Private’ does not exist.
    UATHelper: Packaging (Windows (64-bit)): D:\BadGame\Plugins\discordrpc\Source\DiscordRpc\Private\DiscordRpc.cpp(1): error: Expected DiscordRpc.h to be first header included.
    UATHelper: Packaging (Windows (64-bit)): D:\BadGame\Plugins\discordrpc\Source\DiscordRpc\Private\DiscordRpcBlueprint.cpp(1): error: Expected DiscordRpcBlueprint.h to be first header included.
    PackagingResults: Error: Expected DiscordRpc.h to be first header included.
    PackagingResults: Error: Expected DiscordRpcBlueprint.h to be first header included.
    UATHelper: Packaging (Windows (64-bit)): Writing manifest to D:\BadGame\Intermediate\Build\Manifest.xml
    UATHelper: Packaging (Windows (64-bit)): Building BadGame…
    UATHelper: Packaging (Windows (64-bit)): Using Visual Studio 2019 14.27.29112 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
    UATHelper: Packaging (Windows (64-bit)): Building 3 actions with 8 processes…
    UATHelper: Packaging (Windows (64-bit)): [1/3] Module.DiscordRpc.cpp
    UATHelper: Packaging (Windows (64-bit)): D:\Games\UE_4.25\Engine\Source\BadGame\Plugins\discordrpc\Source\DiscordRpc\Public\DiscordRpc.h(5): fatal error C1083: Cannot open include file: ‘ModuleManager.h’: No such file or directory
    UATHelper: Packaging (Windows (64-bit)): Took 3.0970035s to run UnrealBuildTool.exe, ExitCode=6
    UATHelper: Packaging (Windows (64-bit)): UnrealBuildTool failed. See log for more details. (C:\Users\Jacobb626YT\AppData\Roaming\Unreal Engine\AutomationTool\Logs\D+Games+UE_4.25\UBT-BadGame-Win64-Shipping.txt)
    UATHelper: Packaging (Windows (64-bit)): AutomationTool exiting with ExitCode=6 (6)
    UATHelper: Packaging (Windows (64-bit)): BUILD FAILED
    PackagingResults: Error: Unknown Error

    1. This line has the error: D:\Games\UE_4.25\Engine\Source\BadGame\Plugins\discordrpc\Source\DiscordRpc\Public\DiscordRpc.h(5): fatal error C1083: Cannot open include file: ‘ModuleManager.h’: No such file or directory

      Make sure that ModuleManager.h and the other header files are in the correct folders.

  7. Hello! I am having issues with packaging this. I am able to get it working without issues in the editor, but in either shipping or development it does not work. Accessing the Discord Instance in these packaged versions tells me that the Instance is essentially null. I have gone through the .build.cs many times and cant seem to find any issues there. When packaging, there is also a plugins folder made with the .dll being the only thing in the folder. Thank you!

    1. When packaging for shipping my plugin folder looks like this.

      Config
      Source – DLL is in this folder
      DiscordRpc.uplugin

      Is this similar to yours?

  8. Hello. My plugin works in editor, but not when packaged. After packaging, a plugins folder with the single .dll file is inside. Accessing the Instance in the packaged version gives me the message, “Warning: Accessed None trying to read property Discord Instance”. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *