-
Notifications
You must be signed in to change notification settings - Fork 6
Getting Started
Kayra Uylar edited this page Jul 11, 2025
·
5 revisions
Warning
Discord forces ALL assets to load through /.proxy, which means the default Godot exports will not work. You should use a custom shell that lets Godot to load all the files with that limitation in mind.
Example shells:
- To use this SDK, copy the correct DiscordSDK.gd file to your project.
- For Godot 3.x: https://github.com/kuylar/discord-embedded-godot/blob/master/plugins/DiscordEmbeddedSDK/DiscordSDK.gd
- 3.x is no longer supported and will not receive any updates. The script should be simple, and if required, you should be able to add new commands & events
- For Godot 4.x: https://github.com/kuylar/discord-embedded-godot/blob/godot-4/plugins/DiscordEmbeddedSDK/DiscordSDK.gd
- For Godot 3.x: https://github.com/kuylar/discord-embedded-godot/blob/master/plugins/DiscordEmbeddedSDK/DiscordSDK.gd
- In Project Settings, add the script as an AutoLoad script.
- In your scripts, call
DiscordSDK.init("YOUR_CLIENT_ID")in_ready() - Wait for the
dispatch_readyevent to be fired.- If this event isn't firing, then your client ID might be wrong.
- Call
DiscordSDK.command_authorize("code", ["list", "of", "oauth2", "scopes", "you", "want", "to", "use"], "")- All functions prefixed with
command_are async functions. Make sure to yield/await them!
- All functions prefixed with
- Do the OAuth flow with the code you received from the function call
- In the example code, an endpoint named
/api/authis used. This endpoint is neither included by Discord or Godot. You must implement the server-side part of the OAuth flow and point your code to call that endpoint.
- In the example code, an endpoint named
- Call
DiscordSDK.command_authenticate("OAUTH2_ACCESS_TOKEN_YOU_GOT_FROM_YOUR_BACKEND") - Everything should be working now! Except signals. Call
DiscordSDK.subscribe_to_events()to get all dispatch events indispatch_*signals.- You have to call this function after the authentication flow. Otherwise you will get unauthorized errors
Note
While loading your export in Discord, make sure to load the exported HTML directly. Putting it in an iframe WILL break functionality
Warning
Note that due to strict CORS limitations, your client can only connect to https://<client-id>.discordsays.com. See more about URL mappings here
Fun fact: This repository also works as a sample project, which allows you to test every SDK function!