Launch
There is situations where you want Discord to launch your game. For example, when you accept your friend invite to play the game.
To solve that, you need to register inside Discord client how to launch your game (at least once).
Tip
It's recommended to do that as soon as possible (e.g. when the game open).
Launch Command
func _ready() -> void:
client.register_launch_command(application_id, "/the/for/the/game/executable")
We never know where the user will install the executable, so you should use some logic to find out. For example, registering the current path at runtime:
func _ready() -> void:
client.register_launch_command(application_id, OS.get_executable_path())
Warning
During development (inside Godot Editor) the OS.get_executable_path() will result in the Godot path.
Discord example use deep link (also knows as custom URI scheme in desktops):
func _ready() -> void:
client.register_launch_command(application_id, "yourgame://")
Launch Steam Game
In case your game was installed through Steam, Discord knows how to make Steam launch your game just by using the Steam App ID.
func _ready() -> void:
client.register_launch_steam_application(application_id, steam_app_id)