Skip to content

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:

  1. To use this SDK, copy the correct DiscordSDK.gd file to your project.
  2. In Project Settings, add the script as an AutoLoad script.
  3. In your scripts, call DiscordSDK.init("YOUR_CLIENT_ID") in _ready()
  4. Wait for the dispatch_ready event to be fired.
    • If this event isn't firing, then your client ID might be wrong.
  5. 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!
  6. Do the OAuth flow with the code you received from the function call
    • In the example code, an endpoint named /api/auth is 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.
  7. Call DiscordSDK.command_authenticate("OAUTH2_ACCESS_TOKEN_YOU_GOT_FROM_YOUR_BACKEND")
  8. Everything should be working now! Except signals. Call DiscordSDK.subscribe_to_events() to get all dispatch events in dispatch_* 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!

Clone this wiki locally