Discord Developer Platform Documentation

repository·main·Indexed 27 days ago

https://github.com/discord/discord-api-docs

Official documentation for the Discord Developer Platform, providing details on how third-party applications can access Discord's APIs and features. Includes guides on building Discord Activities using the @discord/embedded-app-sdk, configuring OAuth2 authentication, managing installation contexts, and implementing design principles for interactive experiences.

Tokens
237.7K
Snippets
395
Records
1.1K
Agent score
91%

What's inside discord-api-docs

  1. Overview of Discord Social SDK Core Concepts

    main

    The Discord Social SDK enables the integration of social features directly into games, such as friend lists, messaging, voice chat, and rich presence.

    Unlike traditional SDKs that provide pre-built UI components, the Discord Social SDK provides access to raw data. This allows developers to build fully customized social experiences that match their game's specific aesthetic and user interface requirements.

  2. Overview of Discord Activities development

    main

    Discord Activities are web applications hosted within an iframe that run inside Discord clients on desktop, mobile, and web. To build these applications, you use the Embedded App SDK to facilitate communication between your web app and the Discord client.

    Key resources for getting started:

    • Building an Activity: Follow the guide to build your first Activity using the Embedded App SDK.
    • Development Patterns: Explore common practices to simplify the building process.
    • Lifecycle: Learn how Activities run and their lifecycle within Discord clients.
  3. Overview of Discord OAuth2 authentication types

    main

    Discord's OAuth2 implementation allows developers to build applications that use authentication and access data from the Discord API. Discord supports several specific grant types depending on the application's needs:

    • Authorization Code Grant: Used for standard user authentication flows.
    • Implicit Grant: An alternative authentication flow.
    • Client Credentials: Used for machine-to-machine authentication.
    • Specialized Flows: Modified flows specifically designed for Bots and Webhooks.
  4. Overview of the Discord example app project structure

    main

    The sample application follows this structure:

    • app.js: The main entrypoint for the application.
    • commands.js: Contains slash command payloads and helpers.
    • game.js: Contains logic specific to the Rock, Paper, Scissors game.
    • utils.js: Utility functions and constants.
    • .env: Stores your credentials and IDs.
    • examples/: Contains short, feature-specific sample apps (e.g., button.js, command.js, modal.js, selectMenu.js).
    • package.json: Project dependencies and scripts.
  5. Overview of Discord Social SDK Communication Features

    main

    The Discord Social SDK provides several communication features to facilitate player interaction within games:

    • Messaging & Communication: Supports one-on-one private chat via MessageHandle (Direct Messages) and real-time voice communication via Call inside game lobbies.
    • Lobbies & In-Game Chat: Virtual spaces controlled by the game where players interact through integrated voice and text chat. Membership rules are managed by the game.
    • Linked Channels: Allows games to link in-game chat with Discord server-based text channels directly in the game UI, enabling players to chat in a Discord server without leaving the game environment.
  6. Explore Discord Social SDK Design Guidelines

    main

    The Discord Social SDK design guidelines provide best practices for integrating social features into your game to create a seamless user experience.

    Key areas covered include:

    • Principles: Fundamental best practices for integration.
    • Signing In: Strategies for user authentication and account linking.
    • Connection Points: Integration points for interacting with Discord services.
    • Branding Guidelines: Rules for using Discord brand assets.
    • Unified Friends List: Designing interfaces to see and interact with Discord friends in-game.
    • Direct Messages & Chat History: Implementing private communication and message persistence.
    • Social Settings: Managing access to Discord social settings.
    • Provisional Accounts: Designing for users who do not link Discord accounts.
    • Status & Rich Presence: Displaying player status and game activity.
    • Consoles: Integrating social features on console platforms.
    • Game Friends: Managing and displaying in-game friends.
    • Linked Channels: Linking Discord channels to your game.
  7. Understand Moderation Responsibilities

    main

    Moderation responsibilities are split between Discord and the Game Developer:

    Discord's Responsibility

    Discord's Community Guidelines and Terms of Service apply to content rendered on Discord, including:

    • Text, audio, and video sent within Discord's platform.
    • Text messages appearing on Discord (e.g., in DMs or Linked Channels) sent by players in your game (via linked or provisional accounts).

    Discord may take actions such as platform-wide account bans. Note that a Discord account ban does not automatically affect a player's separate game account, but the player will lose access to SDK features requiring a Discord account connection.

    Game Developer's Responsibility

    Your game's terms and policies apply to content within your game. You are responsible for:

    • Complying with the Discord Social SDK Terms.
    • Creating and enforcing game-specific content policies.
    • In-game content moderation for messages or audio.
    • Implementing UIs for reporting and moderation (e.g., providing ways for players to report violations and reviewing those reports).

    Note: You are responsible for any third-party moderation toolkits or services used and must ensure compliance with applicable terms and laws (including player consent for data processing).

  8. Understand Bot Users and Authorization

    main

    Discord provides bot users for automation. Bot users are authenticated using the bot token found in your application settings. Unlike standard users, bots have full access to most API routes without needing bearer tokens and can connect to the Real Time Gateway.

    Key Differences for Bots:

    • Bots are added to guilds via the OAuth2 API and cannot accept normal invites.
    • Bots cannot have friends or join Group DMs.
    • Bots have a separate set of rate limits.
    • Verified bots do not have a maximum guild limit.

    Warning: Automating standard user accounts (self-bots) is a violation of the Discord Terms of Service.

  9. Understand Discord App Discovery surfaces

    main

    Discord provides several surfaces to make your Bots or Activities discoverable to users:

    App Directory

    A searchable hub where users can find your app by name, category, or collection. It includes a Product Page where you can provide descriptions, images, videos, and links.

    App Launcher

    Accessible via the app shapes icon in Discord, the App Launcher allows discovery through:

    • Recent Apps: Recently used or installed apps.
    • Installed Apps: Apps already in the user's account or server.
    • Curated Collections: User favorites, staff picks, and recommendations.
    • Partner Apps: Apps developed in collaboration with Discord (marked with a "Partner" tag).
    • Promoted Apps: Apps with increased visibility (marked with a "Promoted" tag).

    Note: Search results are ranked by relevance and popularity. Apps with ads or in-app purchases are tagged as "Ad-supported" or "In-App Purchases" on their details page.

    Social Discovery

    • Sharing Links: You can create shareable links to your app's profile page, store page, or specific items to use in Discord, emails, or websites.
    • Rich Presence: Use Rich Presence to show real-time user activity within your app on their Discord profile, driving organic discovery.
  10. Explore next steps for game community development

    main

    After setting up your community server, consider these advanced integration paths:

    • Rich Presence: Implement Rich Presence to show game details, lobby joining status, game launching, and store links in a user's Discord profile.
    • Player Engagement: Build a bot to manage leaderboards, event announcements, and achievement sharing.
    • Community Invites: Implement deep-link community invites for streamlined player onboarding.
  11. Changes to Default Channel behavior

    main

    The 'default' channel for a user is now the channel with the highest position that their permissions allow them to see.

    • New guilds no longer have a default channel with the same ID as the guild.
    • Existing guilds retain their #general channel ID.
    • Discord remembers a user's last-visited channel in a guild across sessions.