Godot - Discord Rich Presence in 5 min
Back in 2017, when Discord was a way smaller deal than it is now, they released a new feature - Rich presence. It was quite a fun way to check what games other people are playing but what’s even more interesting you could view details like:
- what’s the current game state
- How long the game is running
- and even join or spectate
Preview
Today I’m gonna show how to set it up in just a few minutes, how to use all the customisation options and how to integrate that in your Godot game.
Setup your game
First we need to quickly setup our game:
- Go to discord.com/developers and login with your Discord account
- Create a new Application and name it the same as your game.
- Once created, go to the Rich presence tab on the left → Visualiser and start previewing what you can do with Rich presence and how it will look like on Discord
Preview
Add Discord SDK to your game
Once we created our app in Discord, it’s time to add special code to our Godot game to handle Rich Presence.
aside
We'll be using a free open source package called discord-rpc-godot
-
Unzip it and place “addons” folder in the root of your Godot project File SystemPreview
-
Restart Godot editor
-
Go to Project → Project Settings menu and in the ‘Plugins’ tab enable DiscordRPC. A nice popup window will show up, click “Save and restart”
Preview
Create Discord manager script
Now, that we have a DiscordRPC package installed it’s time to to create a new script. It will send info to Discord what player is currently doing in the game.
-
Create a new GD script called
discord_manager.gd
, open it -
Now edit your
_ready
function with those Discord commands:python1discord_sdk.app_id = 182391410223769290 2discord_sdk.state = "Playing" 3discord_sdk.defails = "Hello Discord from Godot!" 4 5discord_sdk.refresh() # Send data to Discord
Enter the APPLICATION ID that can be found in the Discord developer portal (General information tab) -
Save your script. Craft a new Node on the scene (preferably the standard “Node” type) called
discord-manager
-
Add our newly created script to it
Now when we’ll run our game, Discord will also show a rich presence:
Preview
Rich presence customisation
That’s the basic setup, but the good news is that we can customise our Rich presence even further! Check out this example:
Preview
At the beginning I showed you that you can open a Visualiser in Discord dashboard to test out all the different settings - this tool allows us to easily preview the future changes.
Check out this video of mine where I show you how to customise your Godot Rich Presence:
Thank you for reading this post on Coco Code Learn!