Godot - Discord Rich Presence in 5 min

Godot - Discord Rich Presence in 5 min thumbnail
Godot - Discord Rich Presence in 5 min thumbnail
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
Discord Rich Presence demo
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:
  1. Go to discord.com/developers and login with your Discord account
  2. Create a new Application and name it the same as your game.
  3. 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
DRP Customisation
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
  1. Unzip it and place “addons” folder in the root of your Godot project File System
    Godot addons
    Preview
  2. Restart Godot editor
  3. Go to Project → Project Settings menu and in the ‘Plugins’ tab enable DiscordRPC. A nice popup window will show up, click “Save and restart”
Godot RPC - Restart required
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.
  1. Create a new GD script called discord_manager.gd , open it
  2. Now edit your _ready function with those Discord commands:
    python
    1discord_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)
  3. Save your script. Craft a new Node on the scene (preferably the standard “Node” type) called discord-manager
  4. Add our newly created script to it
Now when we’ll run our game, Discord will also show a rich presence:
Our Godot Rich Presence setup
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:
Advanced Rich Presence setup
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:
Implement Discord RICH PRESENCE! thumbnail
YouTube video
Implement Discord RICH PRESENCE!
Thank you for reading this post on Coco Code Learn!
divider
discord
Hi! Why don’t you visit my discord?
Copyright © 2024 Teal Fire