aitsys
npx skills add https://discord-docs.diff.aitsys.dev
Agent 安装分布
Skill 文档
Capabilities
The Discord Developer Platform enables agents to build and manage sophisticated applications that integrate with Discord’s ecosystem. Agents can create interactive bots and apps that respond to user commands, build multiplayer games and social experiences that run directly in Discord, integrate rich social features into games, monetize applications through subscriptions and purchases, and manage server resources with advanced moderation and customization tools.
Skills
Application Development & Interactions
- Create Slash Commands: Build native
/commands that users can invoke in Discord with autocomplete support and parameter validation - Message Components: Add interactive buttons, select menus, and form inputs to messages for rich user interactions
- Modal Forms: Create popup forms to collect structured user input with text fields and validation
- Application Commands: Implement slash commands, user commands (right-click on users), and message commands (right-click on messages)
- Interaction Handling: Receive and respond to interactions via HTTP webhooks or WebSocket Gateway connections with 3-second response deadlines
- Followup Messages: Edit initial responses and send up to 5 followup messages within 15-minute interaction token validity window
Activity Development (Embedded Games & Experiences)
- Build Activities: Create multiplayer games and social experiences using the Embedded App SDK that run in iframes within Discord
- Activity Launching: Launch Activities via Entry Point commands or interaction callbacks (LAUNCH_ACTIVITY type 12)
- SDK Commands: Call Discord client commands for user authentication, fetching activity data, and managing connected users
- SDK Events: Subscribe to events for connection status, user updates, activity instance changes, and voice state modifications
- Cross-Platform Support: Deploy Activities across desktop, mobile, and web clients with responsive design considerations
- Monetization in Activities: Implement in-app purchases using getEntitlements, getSkus, and startPurchase SDK methods
Discord Social SDK Integration
- Account Linking: Enable OAuth2-based Discord account linking across desktop, mobile, and console platforms
- Friends Lists: Create unified friends lists showing Discord friends within games
- Game Invites: Send and manage game invites allowing friends to join multiplayer sessions
- Voice Chat: Integrate real-time voice communication in lobbies with mute, deafen, and volume controls
- Lobbies: Create virtual spaces for player interaction with text/voice chat and metadata support (up to 1,000 members, 25 recommended for voice)
- Direct Messaging: Enable private messaging between players through Discord DMs
- Rich Presence: Display player activity status on Discord profiles with custom assets and join buttons
- Linked Channels: Connect game lobbies to Discord text channels for cross-platform communication
Messaging & Content Management
- Send Messages: Post messages to channels via HTTP API, webhooks, or interaction responses
- Manage Messages: Edit, delete, and retrieve messages with proper permissions
- Webhooks: Create low-effort message posting without bot user authentication
- Message Embeds: Format rich content with embeds supporting up to 10 per message
- Attachments: Upload and manage file attachments with size limits
- Polls: Create native Discord polls with voting options
- Message Flags: Control message visibility (ephemeral), suppress embeds, and enable component-based rendering
Server & Resource Management
- Guild Management: Create, modify, and delete servers with customizable settings
- Channel Operations: Create text/voice channels, manage permissions, and organize channel hierarchies
- Role Management: Create and assign roles with granular permission control
- User Management: Access user profiles, manage guild members, and handle permissions
- Auto Moderation: Set up rules that trigger on keywords, spam, or suspicious activity with automatic actions (block, timeout, remove)
- Audit Logs: Track server changes and administrative actions with detailed logging
- Permissions: Implement role-based access control with 50+ permission flags
Authentication & Authorization
- OAuth2 Authorization Code Grant: Implement standard OAuth2 flow for user authentication with access and refresh tokens
- Scopes Management: Request specific permissions (identify, guilds, commands, etc.) during authorization
- Installation Contexts: Support guild-install (server) and user-install (personal) app installations
- Token Exchange: Exchange authorization codes for access tokens valid for ~7 days with refresh capability
- Provisional Accounts: Create temporary accounts for users without Discord accounts in games
Monetization
- SKU Management: Create one-time purchase and subscription SKUs for premium features
- Entitlements: Check user access to premium features via List Entitlements endpoint with user/guild filtering
- App Subscriptions: Implement recurring billing for premium functionality (user or guild-wide)
- One-Time Purchases: Sell durable items (permanent) or consumable items (single-use)
- Purchase Verification: Verify entitlements before granting premium access in background processes
- Store Pages: Showcase premium offerings on app directory and custom store pages
Events & Real-Time Updates
- Gateway Events: Receive WebSocket-based events for server changes, messages, voice states, and user updates
- Webhook Events: Get HTTP-based events for app authorization, installations, and specific triggers
- Event Subscription: Subscribe to specific event types with filtering and rate limit management
- Voice State Tracking: Monitor user voice channel presence and status changes
- Message Events: Track message creation, updates, and deletions in real-time
Rich Presence & Profile Integration
- Activity Display: Show what users are doing in games on their Discord profiles
- Custom Assets: Upload up to 300 custom images (1024×1024 recommended) for presence visualization
- Invite Images: Create custom invite images for game invitations
- Presence Data: Display scores, duration, listening status, and custom metadata
- Join Buttons: Enable friends to join games directly from presence display
Developer Tools & Resources
- HTTP REST API: Make synchronous requests to retrieve and modify Discord resources
- Gateway WebSocket API: Maintain persistent connections for real-time event streaming
- Rate Limiting: Handle rate limits with exponential backoff and per-endpoint quotas
- Security Validation: Verify request signatures using Ed25519 with X-Signature headers
- Community Libraries: Access language-specific SDKs for JavaScript, Python, C#, Go, and more
- Sample Projects: Use starter templates and reference implementations for Activities and apps
Workflows
Building a Discord Bot with Slash Commands
- Create an application in the Developer Portal and obtain Client ID
- Register slash commands via HTTP API with name, description, and options
- Configure Interactions Endpoint URL for HTTP-based interaction delivery
- Implement endpoint to acknowledge PING requests (type 1) with PONG response
- Validate incoming interaction signatures using Ed25519 verification
- Parse interaction payload to extract command name and user-provided options
- Execute business logic based on command type
- Respond within 3 seconds using interaction callback endpoint with message content
- Send followup messages if needed within 15-minute token validity window
- Install app to servers via OAuth2 authorization with appropriate scopes
Creating a Multiplayer Activity
- Enable Activities in app settings and receive default Entry Point command
- Initialize Embedded App SDK with client ID in frontend code
- Call
discordSdk.ready()to establish connection with Discord client - Authenticate users via
authorize()method with required scopes - Fetch activity instance data using SDK commands
- Subscribe to SDK events for user updates and voice state changes
- Implement game logic with real-time synchronization
- Set Rich Presence using SDK to show player activity
- Handle voice chat by managing lobbies and voice connections
- Implement monetization by checking entitlements before granting premium features
- Deploy as web app accessible via HTTPS with proper CSP headers
Integrating Discord Social SDK into a Game
- Download Discord Social SDK for target platform (C++, Unity, Unreal Engine)
- Initialize SDK with application credentials
- Implement OAuth2 account linking flow to connect Discord accounts
- Create lobbies for multiplayer sessions with metadata
- Add friends list UI showing Discord friends
- Implement voice chat in lobbies with audio callbacks
- Send game invites to friends via SDK methods
- Set Rich Presence to display current game activity
- Link game lobbies to Discord text channels for cross-platform chat
- Handle provisional accounts for players without Discord accounts
- Test on target platforms (desktop, mobile, console) before release
Implementing App Monetization
- Enable monetization in app settings
- Create SKUs for premium features (subscriptions or one-time purchases)
- Set pricing and billing cycles for subscription SKUs
- Implement purchase UI using Embedded App SDK methods (getSkus, startPurchase)
- Listen for purchase completion events
- Query List Entitlements endpoint to verify user access
- Grant premium features only to users with active entitlements
- Handle subscription cancellations and refunds
- Track entitlements in database for background processes
- Display premium benefits on app directory and store pages
Setting Up Server Moderation
- Create Auto Moderation rules via HTTP API with trigger types (keywords, spam, etc.)
- Define rule actions (block message, timeout user, remove message)
- Exempt specific roles and channels from rules
- Listen to Auto Moderation events via Gateway (requires MANAGE_GUILD permission)
- Log triggered rules to audit log for review
- Implement custom moderation commands using slash commands
- Use permissions system to restrict moderation commands to authorized users
- Monitor audit logs for administrative actions
- Create role-based access control for sensitive operations
- Implement appeals process for moderation actions
Integration
Discord apps integrate with external systems through:
- OAuth2 Scopes: Request specific permissions (identify, email, guilds, commands) during authorization
- Webhook Delivery: Receive events via HTTP POST to configured endpoints
- API Rate Limits: Respect per-endpoint and global rate limits with retry logic
- Third-Party Libraries: Use community-maintained SDKs for faster development
- External Resources: Load images and assets from external URLs with CSP compliance
- Game Engines: Integrate with Unity, Unreal Engine, and custom game engines via Social SDK
- Database Integration: Store user data, entitlements, and game state in external databases
- Voice Systems: Integrate custom audio processing with Discord voice infrastructure
Context
Installation Contexts: Apps can be installed to servers (guild-install) or user accounts (user-install), affecting where commands appear and who can use them.
Interaction Tokens: Valid for 15 minutes; initial response required within 3 seconds or token invalidates. Followup messages can be sent throughout token validity.
Rate Limits: Discord enforces per-endpoint and global rate limits. Communication features in Social SDK have additional caps requiring approval for production use.
Permissions: Apps require explicit permissions (MANAGE_GUILD, MANAGE_CHANNELS, etc.) to perform actions. User permissions are checked at interaction time.
Scopes: OAuth2 scopes determine what data apps can access (identify, email, guilds, commands, etc.). Different scopes required for different features.
Entitlements: Represent user access to premium features. Must be verified before granting access; available via HTTP API with filtering options.
Activities: Run in iframes with postMessage protocol for communication. Support cross-platform deployment with responsive design requirements.
Rich Presence: Publicly visible on user profiles; use test accounts during development. Assets must be 1024×1024; up to 300 custom assets per app.
Voice Limits: Lobbies support up to 1,000 members but voice calls recommended for 25 or fewer participants.
Security: All HTTP requests require valid Content-Type headers. Interaction signatures must be validated using Ed25519. Webhook endpoints must acknowledge PING requests.
For additional documentation and navigation, see: https://discord-docs.diff.aitsys.dev/llms.txt