Build production-ready Discord bots with Discord.js (JavaScript) and Pycord (Python) — gateway intents, slash commands, interactive components, rate limiting, and sharding. USE WHEN building, structuring, or scaling a Discord bot and choosing intents, commands, components, or a sharding strategy.
Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
Build production-ready Discord bots with Discord.js (JavaScript) and Pycord (Python) — gateway intents, slash commands, interactive components, rate limiting, and sharding. USE WHEN building, structuring, or scaling a Discord bot and choosing intents, commands, components, or a sharding strategy.
cluster
python-backend
version
1.0.0
origin
antigravity-awesome-skills (MIT)
risk
unknown
source
vibeship-spawner-skills (Apache 2.0)
date_added
"2026-02-27T00:00:00.000Z"
Discord Bot Architect
Specialized skill for building production-ready Discord bots.
Covers Discord.js (JavaScript) and Pycord (Python), gateway intents,
slash commands, interactive components, rate limiting, and sharding.
Principles
Slash commands over message parsing (Message Content Intent deprecated)
Acknowledge interactions within 3 seconds, always
Request only required intents (minimize privileged intents)
Handle rate limits gracefully with exponential backoff
Plan for sharding from the start (required at 2500+ guilds)
Use components (buttons, selects, modals) for rich UX
Test with guild commands first, deploy global when ready
Patterns
Discord.js v14 Foundation
Modern Discord bot setup with Discord.js v14 and slash commands
When to use: Building Discord bots with JavaScript/TypeScript,Need full gateway connection with events,Building bots with complex interactions
# Pycord - AutoShardedBotimport discord
from discord.ext import commands
# Automatically handles sharding
bot = commands.AutoShardedBot(
command_prefix="!",
intents=discord.Intents.default(),
shard_count=None# Auto-determine
)
@bot.eventasyncdefon_ready():
print(f"Logged in on {len(bot.shards)} shards")
for shard_id, shard in bot.shards.items():
print(f"Shard {shard_id}: {shard.latency * 1000:.2f}ms")
@bot.eventasyncdefon_shard_ready(shard_id):
print(f"Shard {shard_id} is ready")
# Get guilds per shardfor shard_id, guilds in bot.guilds_by_shard().items():
print(f"Shard {shard_id}: {len(guilds)} guilds")
Scaling_guide
1-2500 guilds: No sharding required
2500+ guilds: Sharding required by Discord
Recommended: ~1000 guilds per shard
Memory: Each shard runs in separate process
Sharp Edges
Interaction Timeout (3 Second Rule)
Severity: CRITICAL
Situation: Handling slash commands, buttons, select menus, or modals
Symptoms:
User sees "This interaction failed" or "The application did not respond."
Command works locally but fails in production.
Slow operations never complete.
Why this breaks:
Discord requires ALL interactions to be acknowledged within 3 seconds:
Slash commands
Button clicks
Select menu selections
Context menu commands
If you do ANY slow operation (database, API, file I/O) before responding,
you'll miss the window. Discord shows an error even if your bot processes
the request correctly afterward.
After acknowledgment, you have 15 minutes for follow-up responses.
Recommended fix:
Acknowledge immediately, process later
// Discord.js - Defer for slow operationsmodule.exports = {
asyncexecute(interaction) {
// DEFER IMMEDIATELY - before any slow operationawait interaction.deferReply();
// For ephemeral: await interaction.deferReply({ ephemeral: true });// Now you have 15 minutesconst result = awaitslowDatabaseQuery();
const aiResponse = awaitcallLLM(result);
// Edit the deferred replyawait interaction.editReply(`Result: ${aiResponse}`);
}
};
# Pycord@bot.slash_command()asyncdefslow_command(ctx):
await ctx.defer() # Acknowledge immediately# await ctx.defer(ephemeral=True) # For private response
result = await slow_operation()
await ctx.followup.send(f"Result: {result}")
For components (buttons, menus)
// If you're updating the messageawait interaction.deferUpdate();
// If you're sending a new responseawait interaction.deferReply({ ephemeral: true });
Missing Privileged Intent Configuration
Severity: CRITICAL
Situation: Bot needs member data, presences, or message content
Symptoms:
Members intent: member lists empty, on_member_join doesn't fire
Presences intent: statuses always unknown/offline
Message content intent: message.content is empty string
Why this breaks:
Discord has 3 privileged intents that require manual enablement:
GUILD_MEMBERS - Member join/leave, member lists
GUILD_PRESENCES - Online status, activities
MESSAGE_CONTENT - Read message text (deprecated for commands)
At 100+ servers, you need Discord verification to keep using them.
Recommended fix:
Step 1: Enable in Developer Portal
1. Go to https://discord.com/developers/applications
2. Select your application
3. Go to Bot section
4. Scroll to Privileged Gateway Intents
5. Toggle ON the intents you need
Use slash commands, buttons, and modals instead of message parsing.
These don't require the Message Content intent.
Command Registration Rate Limited
Severity: HIGH
Situation: Registering slash commands
Symptoms:
Commands not appearing. 429 errors when deploying.
"You are being rate limited" messages.
Commands appear for some guilds but not others.
Why this breaks:
Command registration is rate limited:
Global commands: 200 creates/day, updates take up to 1 hour to propagate
Guild commands: 200 creates/day per guild, instant update
Common mistakes:
Registering commands on every bot startup
Registering in every guild separately
Making changes in a loop without delays
Recommended fix:
Use a separate deploy script (not on startup)
// deploy-commands.js - Run manually, not on bot startconst { REST, Routes } = require('discord.js');
const rest = newREST().setToken(process.env.DISCORD_TOKEN);
asyncfunctiondeploy() {
// For development: Guild commands (instant)if (process.env.GUILD_ID) {
await rest.put(
Routes.applicationGuildCommands(
process.env.CLIENT_ID,
process.env.GUILD_ID
),
{ body: commands }
);
console.log('Guild commands deployed instantly');
}
// For production: Global commands (up to 1 hour)else {
await rest.put(
Routes.applicationCommands(process.env.CLIENT_ID),
{ body: commands }
);
console.log('Global commands deployed (may take up to 1 hour)');
}
}
deploy();
# Pycord - Don't sync on every startup@bot.eventasyncdefon_ready():
# DON'T DO THIS:# await bot.sync_commands()print(f"Ready! Commands should already be registered.")
# Instead, sync manually or use a flagif __name__ == "__main__":
if"--sync"in sys.argv:
# Only sync when explicitly requested
bot.sync_commands_on_start = True
bot.run(token)
Testing workflow
Use guild commands during development (instant updates)
Only deploy global commands when ready for production
Run deploy script manually, not on every restart
Bot Token Exposed
Severity: CRITICAL
Situation: Storing or sharing bot token
Symptoms:
Unauthorized actions from your bot.
Bot joins random servers.
Bot sends spam or malicious content.
"Invalid token" after Discord invalidates it.
Why this breaks:
Your bot token provides FULL control over your bot. Attackers can:
Send messages as your bot
Join servers, create invites
Access all data your bot can access
Potentially take over servers where bot has admin
Discord actively scans GitHub for exposed tokens and invalidates them.
Common exposure points:
Committed to Git
Shared in Discord itself
In client-side code
In public screenshots
Recommended fix:
Never hardcode tokens
// BAD - never do thisconst token = 'MTIzNDU2Nzg5MDEyMzQ1Njc4.ABCDEF.xyz...';
// GOOD - environment variablesrequire('dotenv').config();
client.login(process.env.DISCORD_TOKEN);
Use .gitignore
# .gitignore
.env
.env.local
config.json
If token is exposed
Go to Developer Portal immediately
Regenerate the token
Update all deployments
Review bot activity for unauthorized actions
Check git history and force push to remove if needed
// Load with dotenvrequire('dotenv').config();
const token = process.env.DISCORD_TOKEN;
Bot Missing applications.commands Scope
Severity: HIGH
Situation: Slash commands not appearing for users
Symptoms:
Bot is in server but slash commands don't show up.
Typing / shows no commands from your bot.
Commands worked in development server but not others.
Why this breaks:
Discord has two important OAuth scopes:
bot - Traditional bot permissions (messages, reactions, etc.)
applications.commands - Slash command permissions
Many bots were invited with only the bot scope before slash commands
existed. They need to be re-invited with both scopes.