Discord๏
Inherits: Object
Discord Social SDK integration for RPC rich presence, OAuth, invites, and relationships.
Description๏
The Discord singleton dynamically loads the Discord Partner SDK library at runtime. Use initialize_presence_only() for auth-less RPC rich presence, or initialize() for the full OAuth social layer (friends, invites, server auth).
Pump run_callbacks() each frame (or rely on the engine frame hook) while the client is active.
Methods๏
Signals๏
activity_invite_accepted(join_secret: String) ๐
Emitted when the local user accepts an activity invite.
activity_invite_created(invite: Dictionary) ๐
Emitted when a new activity invite is received.
activity_invite_sent() ๐
Emitted after send_activity_invite() completes successfully.
activity_invite_updated(invite: Dictionary) ๐
Emitted when an existing activity invite is updated.
activity_join_requested(join_secret: String) ๐
Emitted when another user requests to join via the Discord client Join button.
authorization_failed(error: String) ๐
Emitted when OAuth authorization fails.
authorization_started() ๐
Emitted when OAuth authorization begins and the user must approve access.
authorized() ๐
Emitted when OAuth authorization succeeds before the client reaches ready state.
connection_state_changed(state: int, error: int, error_detail: int) ๐
Emitted when the Discord client connection state changes.
lobby_joined(lobby_id: int) ๐
Emitted when create_or_join_lobby() succeeds.
ready() ๐
Emitted when Discord is ready for rich presence updates.
relationship_action_completed(action: String, user_id: int, success: bool, error: String) ๐
Emitted when an OAuth relationship action completes.
relationship_created(user_id: int, is_discord: bool) ๐
Emitted when a new relationship is created. OAuth only.
relationship_deleted(user_id: int, is_discord: bool) ๐
Emitted when a relationship is removed. OAuth only.
relationship_groups_updated(user_id: int) ๐
Emitted when unified friends list groups should be refreshed. OAuth only.
relationships_updated(count: int) ๐
Emitted when the relationship count is refreshed after connect.
rich_presence_updated(success: bool, error: String) ๐
Emitted when a rich presence update completes.
user_updated(user_id: int) ๐
Emitted when a Discord user's profile or status changes. OAuth only.
Enumerations๏
enum ConnectionState: ๐
ConnectionState STATE_DISCONNECTED = 0
There is currently no description for this enum. Please help us by contributing one!
ConnectionState STATE_CONNECTING = 1
There is currently no description for this enum. Please help us by contributing one!
ConnectionState STATE_CONNECTED = 2
There is currently no description for this enum. Please help us by contributing one!
ConnectionState STATE_READY = 3
There is currently no description for this enum. Please help us by contributing one!
ConnectionState STATE_RECONNECTING = 4
There is currently no description for this enum. Please help us by contributing one!
ConnectionState STATE_DISCONNECTING = 5
There is currently no description for this enum. Please help us by contributing one!
ConnectionState STATE_HTTP_WAIT = 6
There is currently no description for this enum. Please help us by contributing one!
enum AuthState: ๐
AuthState AUTH_NONE = 0
There is currently no description for this enum. Please help us by contributing one!
AuthState AUTH_PENDING = 1
There is currently no description for this enum. Please help us by contributing one!
AuthState AUTH_AUTHORIZED = 2
There is currently no description for this enum. Please help us by contributing one!
AuthState AUTH_READY = 3
There is currently no description for this enum. Please help us by contributing one!
AuthState AUTH_FAILED = 4
There is currently no description for this enum. Please help us by contributing one!
enum RelationshipType: ๐
RelationshipType RELATIONSHIP_NONE = 0
There is currently no description for this enum. Please help us by contributing one!
RelationshipType RELATIONSHIP_FRIEND = 1
There is currently no description for this enum. Please help us by contributing one!
RelationshipType RELATIONSHIP_BLOCKED = 2
There is currently no description for this enum. Please help us by contributing one!
RelationshipType RELATIONSHIP_PENDING_INCOMING = 3
There is currently no description for this enum. Please help us by contributing one!
RelationshipType RELATIONSHIP_PENDING_OUTGOING = 4
There is currently no description for this enum. Please help us by contributing one!
RelationshipType RELATIONSHIP_IMPLICIT = 5
There is currently no description for this enum. Please help us by contributing one!
RelationshipType RELATIONSHIP_SUGGESTION = 6
There is currently no description for this enum. Please help us by contributing one!
enum RelationshipGroupType: ๐
RelationshipGroupType GROUP_ONLINE_PLAYING_GAME = 0
There is currently no description for this enum. Please help us by contributing one!
RelationshipGroupType GROUP_ONLINE_ELSEWHERE = 1
There is currently no description for this enum. Please help us by contributing one!
RelationshipGroupType GROUP_OFFLINE = 2
There is currently no description for this enum. Please help us by contributing one!
enum StatusType: ๐
StatusType STATUS_ONLINE = 0
There is currently no description for this enum. Please help us by contributing one!
StatusType STATUS_OFFLINE = 1
There is currently no description for this enum. Please help us by contributing one!
StatusType STATUS_BLOCKED = 2
There is currently no description for this enum. Please help us by contributing one!
StatusType STATUS_IDLE = 3
There is currently no description for this enum. Please help us by contributing one!
StatusType STATUS_DND = 4
There is currently no description for this enum. Please help us by contributing one!
StatusType STATUS_INVISIBLE = 5
There is currently no description for this enum. Please help us by contributing one!
StatusType STATUS_STREAMING = 6
There is currently no description for this enum. Please help us by contributing one!
StatusType STATUS_UNKNOWN = 7
There is currently no description for this enum. Please help us by contributing one!
Method Descriptions๏
void accept_activity_invite(invite: Dictionary) ๐
Accepts an activity invite built from activity_invite_created / activity_invite_updated payload fields. Requires OAuth (AUTH_READY).
void accept_discord_friend_request(user_id: int) ๐
Accepts a pending Discord-wide friend request. OAuth only. Emits relationship_action_completed.
void accept_game_friend_request(user_id: int) ๐
Accepts a pending game-scoped friend request. OAuth only. Emits relationship_action_completed.
DiscordAuthResult authenticate_with_server(url: String, access_token: String, client_id: int) ๐
POSTs the OAuth access token to the auth server and returns the parsed response. Requires AUTH_READY and a non-empty access token.
void block_user(user_id: int) ๐
Blocks a user. OAuth only. Emits relationship_action_completed.
void cancel_discord_friend_request(user_id: int) ๐
Cancels an outgoing Discord friend request. OAuth only.
void cancel_game_friend_request(user_id: int) ๐
Cancels an outgoing game friend request. OAuth only.
void clear_debug_log() ๐
Clears the in-memory debug log buffer.
void clear_rich_presence() ๐
Clears the player's Discord rich presence. Requires presence readiness (is_ready_for_presence()).
void create_or_join_lobby(secret: String) ๐
Creates or joins a Discord lobby by secret. OAuth only. Emits lobby_joined on success.
String get_access_token() const ๐
Returns the OAuth access token obtained during initialize(), or an empty string when not connected.
AuthState get_auth_state() const ๐
Returns the current OAuth/auth lifecycle state.
ConnectionState get_connection_state() const ๐
Returns the current Discord SDK connection state.
Array get_debug_log() const ๐
Returns recent lifecycle and SDK log lines.
String get_default_communication_scopes() const ๐
Returns the default OAuth scopes for communication features.
String get_default_presence_scopes() const ๐
Returns the default OAuth scopes for rich presence and friends list.
Dictionary get_game_activity() ๐
Returns the current user's game-associated activity readback, or an empty dictionary when unavailable.
String get_granted_scopes() const ๐
Returns the OAuth scopes granted by Discord after token exchange.
String get_last_error() const ๐
Returns the most recent error message.
Dictionary get_relationship(user_id: int) ๐
Returns a relationship dictionary for user_id, or empty when unavailable. OAuth only.
Array get_relationships() ๐
Returns all relationships as an array of dictionaries. OAuth only.
Array get_relationships_by_group(group: RelationshipGroupType) ๐
Returns relationships for a unified friends list group. OAuth only.
int get_relationships_count() const ๐
Returns the cached relationships count after AUTH_READY, or -1 when unavailable.
String get_requested_scopes() const ๐
Returns the OAuth scopes requested during the current auth flow.
Dictionary get_user(user_id: int) ๐
Returns a user dictionary for user_id. OAuth only.
Returns the connected Discord user snowflake ID after AUTH_READY, or 0.
String get_username() const ๐
Returns the connected Discord display or username after AUTH_READY.
Dictionary get_version() const ๐
Returns SDK version metadata and runtime library availability.
Error initialize(client_id: int = 0) ๐
Initializes the Discord Social SDK and starts the OAuth authorization flow.
Error initialize_presence_only(client_id: int) ๐
Initializes RPC rich presence without OAuth or initialize()'s connect step. Sets is_presence_only_mode() and emits ready immediately.
bool is_authorization_pending() const ๐
Returns true while waiting for OAuth (AUTH_PENDING).
bool is_authorized() const ๐
Returns true after token exchange succeeds.
Returns true when the Discord Partner SDK runtime library is present.
bool is_client_active() const ๐
Returns true while the SDK client session is active.
bool is_debug_logging_enabled() const ๐
Returns whether debug logging is enabled.
bool is_frame_hook_connected() const ๐
Returns whether the engine frame hook is connected for automatic callback pumping.
bool is_initialized() const ๐
Returns true after a successful initialize() or initialize_presence_only().
bool is_presence_only_mode() const ๐
Returns true when initialized via initialize_presence_only() (RPC, no OAuth).
bool is_ready_for_presence() const ๐
Returns true when rich presence can be updated (RPC mode or AUTH_READY).
void refresh_relationships() ๐
Refreshes the cached relationship count and emits relationships_updated. OAuth only.
bool register_launch_command(application_id: int, command: String) ๐
Registers a custom launch command for Discord deep links. Works in RPC and OAuth modes.
bool register_launch_steam_application(application_id: int, steam_app_id: int) ๐
Registers Steam launch integration for Discord join flows. Works in RPC and OAuth modes.
void reject_discord_friend_request(user_id: int) ๐
Rejects a pending Discord friend request. OAuth only.
void reject_game_friend_request(user_id: int) ๐
Rejects a pending game friend request. OAuth only.
void remove_discord_and_game_friend(user_id: int) ๐
Removes both Discord and game friendship. OAuth only.
void remove_game_friend(user_id: int) ๐
Removes a game-scoped friend. OAuth only.
void run_callbacks() ๐
Pumps Discord SDK callbacks. Also invoked automatically each frame when initialized.
void send_activity_invite(user_id: int, content: String = "") ๐
Sends an activity invite with optional message text. OAuth only. Emits activity_invite_sent.
void send_activity_join_request(user_id: int) ๐
Sends a join request to another user. OAuth only.
void send_activity_join_request_reply(invite: Dictionary) ๐
Replies to an activity join request invite. OAuth only.
void send_discord_friend_request(username: String) ๐
Sends a Discord-wide friend request by username. OAuth only.
void send_discord_friend_request_by_id(user_id: int) ๐
Sends a Discord-wide friend request by user ID. OAuth only.
void send_game_friend_request(username: String) ๐
Sends a game-scoped friend request by username. OAuth only.
void send_game_friend_request_by_id(user_id: int) ๐
Sends a game-scoped friend request by user ID. OAuth only.
void set_debug_logging(enabled: bool) ๐
Enables verbose SDK file logging in user data.
void shutdown() ๐
Shuts down the Discord SDK session and releases resources.
void unblock_user(user_id: int) ๐
Unblocks a user. OAuth only.
Error update_rich_presence(activity: Dictionary) ๐
Updates Discord rich presence. Keys include type, name, details, state, details_url, state_url, asset fields, invite_cover_image, status_display_type (name/state/details), supported_platforms (array or bitmask), party_id, party_current, party_max, join_secret, buttons ({label,url}), and timestamps. Cached if called before ready.