Skip to main content
These guides cover practical integration tasks for the Discord Social SDK.

Debug & Log

Enable logging and install debugging symbols to troubleshoot SDK issues.

Use with Discord APIs

Combine the SDK with Discord’s REST APIs for server-side operations.

Integrate Moderation

Implement content moderation for text and audio in your game.

Handle Special Characters

Properly render Unicode characters in Discord display names.

Debug and Log

Debugging symbols

Debugging symbols are hosted at https://storage.googleapis.com/discord-public-symbols. In Visual Studio, add this URL under Tools → Options → Debugging → Symbols.

Logging

Use Client::AddLogCallback to receive log messages. Use Client::SetLogDir to write logs to a directory.
client->AddLogCallback([](auto message, auto severity) {
    std::cout << "[" << EnumToString(severity) << "] " << message << std::endl;
}, discordpp::LoggingSeverity::Info);
For production builds use ERROR (4) or WARN (3). For development use INFO (2) or VERBOSE (1) for more detail.

Audio logging

Use Client::SetAecDump to enable diagnostic recording of audio input/output for troubleshooting echo cancellation (AEC) issues.

Use with Discord APIs

The SDK handles client-side functionality. Use Discord’s REST API from your game backend for server-side operations.

Authentication

curl -X GET https://discord.com/api/v10/users/@me \
  -H "Authorization: Bot YOUR_BOT_TOKEN"
Always prefix bot tokens with Bot in the Authorization header.

OAuth2 token exchange

import requests

def exchange_code(code, redirect_uri):
    data = {
        'client_id': 'YOUR_CLIENT_ID',
        'client_secret': 'YOUR_CLIENT_SECRET',
        'grant_type': 'authorization_code',
        'code': code,
        'redirect_uri': redirect_uri
    }
    response = requests.post('https://discord.com/api/v10/oauth2/token', data=data)
    return response.json()

Using the OpenAPI spec

Use the Discord OpenAPI Spec with a code generator like openapi-generator.tech to generate a typed client for your backend language. Best practices:
  • Never expose bot tokens in client-side code
  • Respect Discord’s rate limits and implement exponential backoff
  • Cache responses when appropriate

Integrate Moderation

Effective moderation is required under the Discord Social SDK Terms.

Your responsibilities

  • On Discord: Discord’s Community Guidelines and Terms of Service apply to content rendered on Discord (including lobby/DM messages from your game). Discord can take platform-level actions on Discord accounts.
  • In your game: You are responsible for your own content policies, in-game moderation, and providing players a way to report violations.
You are responsible for any third-party moderation services you use, including obtaining required player consents.

Server-side chat moderation

Discord’s moderation metadata API lets your backend attach moderation_metadata to messages. The metadata is delivered to active game sessions via GAME_DIRECT_MESSAGE_UPDATE or LOBBY_MESSAGE_UPDATE webhook events — no polling required.
1

Receive webhook event

Your backend receives a webhook when a message is created or updated.
2

Evaluate the message

Run your moderation logic against the message content.
3

Attach metadata

POST moderation metadata back to Discord’s API for the message.
4

Metadata delivered

Active game sessions receive the metadata via webhook events in real time.

Client-side audio moderation

Use Client::SetAudioModerationCallback to receive callbacks when audio content requires moderation review.

Handling banned Discord accounts

A Discord account ban does not affect the player’s separate game account. However, a banned Discord account loses access to SDK features that require an account connection (such as voice chat and lobbies).

Handle Special Characters in Display Names

Discord display names can contain Unicode characters including emoji, CJK characters, RTL text, and combining diacritics.

Rendering guidelines

  • Use a Unicode-aware font and text rendering library
  • Normalize strings using NFC (canonical decomposition + canonical composition) before display
  • Sanitize display names before inserting into HTML contexts to prevent XSS

Truncation

Truncate on grapheme cluster boundaries rather than byte or code point boundaries to avoid splitting multi-byte characters.
// Get the display name
std::string displayName = user.DisplayName();
// Use a Unicode library (e.g., ICU) to truncate correctly

Sorting and comparison

Use locale-aware collation for sorting friend lists. Avoid byte-by-byte string comparison for user-visible ordering.
Discord display names may contain zero-width characters. Strip zero-width joiners/non-joiners if you use display names as keys in data structures.

Next steps

Managing Lobbies

Create lobbies and manage voice chat for multiplayer games.

Social SDK Overview

Return to the Social SDK overview for a full feature summary.