Addon for Discord integration, built for Godot 4.0.2 as a GDExtension
Uses Discord GameSDK version v2.5.6 (At the time of writing, the latest version v3.2.1 had a bug with ClearActivity)
- linux, macos Github Action workflows
Only some features are implemented as much of the SDK is deprecated.
- Activity
- Rich Presence
- Invites, Ask to Join
- Register application launch command / steam id
- Relationship
- Get friends list
- User
- Get user info, such as name and avatar URL
- Download the Discord GameSDK and copy the libs for your platform(s) from
discord_game_sdk_v2.5.6/lib/x86_64/
toaddons/discord/bin/
- Initialize and update the git submodule godot_cpp to the commit id that corresponds to your version of Godot. This step is to ensure the C++ bindings match.
- Build the extension using
scons
More info here - Copy
addons/
folder into your Godot project
After building and copying the the addons/
folder into your Godot project, the following singletons are available in GDScript
Discord
DiscordUserManager
DiscordRelationshipManager
DiscordActivityManager
Initialize Discord using your app id:
var result = Discord.initialize(1047702455569354813, Discord.NoRequireDiscord)
if result != Discord.Ok:
return push_error("Failed to create Discord object")
var discord_ready = true
then run callbacks every tick:
func _process(_delta):
if discord_ready:
Discord.run_callbacks()
Note: you can use lambda functions for callbacks
Logging:
var log_callback = func(log_level, msg):
print("Discord Log | %d | %s" % [log_level, msg])
Discord.set_log_hook(Discord.Debug, log_callback)
Rich Presence:
var act = DiscordActivity.new()
act.state = "Coding Solo"
act.details = "Writing code"
DiscordActivityManager.update_activity(act, func (res):
print(res)
)
Refer to the Discord GameSDK documentation for details on the functions, structs, and callbacks