# Discord

> Discord API Skill

- Skill: `ashish7802/discord` (Agent Skill, multi-file: 9 files)
- Install (CLI): `npx skillmds@latest add ashish7802/discord`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ashish7802/discord/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: ashish7802 (https://skillmd.com/u/ashish7802)
- Updated: 2026-09-21
- Page: https://skillmd.com/skills/ashish7802/discord

---

# Discord API Skill

## Overview
The Discord API allows you to build bots, automate servers, and manage webhooks. This skill focuses on the `discord.js` library for bot integration.

## Installation
```bash
npm install discord.js
pip install discord.py
```

## Authentication
Bots authenticate using a Bot Token provided in the `Authorization: Bot <token>` header (handled automatically by the SDK).

## Core Concepts
- **Guild**: A Discord server.
- **Intents**: WebSocket subscription flags defining what events the bot receives.
- **Slash Commands**: Application commands registered to Discord.

## Common Workflows
1. Initialize `Client` with Intents.
2. Login using `client.login(TOKEN)`.
3. Listen to `interactionCreate` to handle Slash Commands.

## Error Handling
Handle `DiscordAPIError`. Code 50013 indicates 'Missing Permissions'. Code 10008 indicates 'Unknown Message'.

## Security
Never commit your Bot Token. If leaked, Discord will automatically reset it, crashing your application.

## Rate Limits
Global rate limits are 50 requests per second. Route-specific limits exist (e.g., renaming channels is highly restricted).

## Best Practices
Always use Slash Commands (`interactionCreate`) rather than parsing text messages (`messageCreate`). Text message intent is restricted.

## Troubleshooting
If your bot stops receiving events, verify that the required Privileged Intents (like Guild Members) are enabled in the Discord Developer Portal.

## References
- [API Reference](https://discord.com/developers/docs/intro)

## Why use this skill
Use this when your agent works with **discord** — structured patterns beat pasted docs and prevent common hallucinations.

## AI pitfalls
- Using outdated SDK or API versions from training data
- Inventing environment variable names
- Omitting error handling and retry logic

## Production checklist
- [ ] Secrets in environment variables, not source code
- [ ] Error handling and logging in place
- [ ] Rate limits and timeouts configured

## Related skills
- [`express`](../express/SKILL.md) — integrates with
- [`fastapi`](../fastapi/SKILL.md) — integrates with

---
> **Last Verified:** 2026-07-02

