Skip to main content

Overview

The Discord Social SDK provides client-side functionality for integrating Discord social features into your game. However, if you use a game backend, you should interact with Discord’s HTTP APIs for server-side operations when possible.

Prerequisites

Before you begin, make sure you have:
  • A Discord application created in the Developer Portal
  • Access to your application’s bot token
  • Required OAuth2 scopes configured

Authentication Types

Bot Token Authentication

For server-to-server communication:
Always prefix your bot token with Bot in the Authorization header!

Bearer Token Authentication

For authenticated user actions:

Common API Operations

OAuth2 Token Exchange

Exchange an authorization code for an access token:

User Information

Get information about the authenticated user:

Using the OpenAPI Specification

You can use the Discord OpenAPI Spec to generate a client in your preferred backend language to make it easier to call the various APIs. A good tool for that is https://openapi-generator.tech/. In python for example, that might look like this:

Best Practices

  1. Token Security
    • Never expose bot tokens in client-side code
    • Store tokens securely
  2. Rate Limiting
    • Respect Discord’s rate limits
    • Implement exponential backoff
    • Cache responses when appropriate
  3. Error Handling
    • Handle HTTP errors gracefully
    • Implement retry logic for transient failures
    • Log API errors for debugging

Next Steps

Now that you’ve set up Rich Presence, you might want to explore:

Managing Game Invites

Allow players to invite friends to join their game session or party.

Managing Lobbies

Bring players together in a shared lobby with invites, text chat, and voice comms.

Design Guidelines for Rich Presence

Best practices for Rich Presence UI/UX.
Need help? Join the Discord Developers Server and share questions in the #social-sdk-dev-help channel for support from the community. If you encounter a bug while working with the Social SDK, please report it here: https://dis.gd/social-sdk-bug-report

Change Log