Skill

Build Production-Ready Discord Bots

Specialized skill for production-ready Discord bots in Discord.js and Pycord - gateway intents, slash commands, components, rate limiting, and sharding.

Works with discord

79
Spark score
out of 100
Updated last month
Version 13.1.0

Add to Favorites

Why it matters

Develop robust and scalable Discord bots using modern JavaScript (Discord.js) or Python (Pycord) frameworks. This asset provides foundational code, architectural patterns, and best practices for creating production-ready bots.

Outcomes

What it gets done

01

Generate boilerplate code for Discord bots with Discord.js v14 or Pycord.

02

Implement slash commands, interactive components (buttons, modals), and event handlers.

03

Incorporate best practices for rate limiting, intent management, and sharding.

04

Provide example structures for command and event handling, including cog-based organization for Pycord.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-discord-bot-architect | bash

Overview

Discord Bot Architect

A Discord bot architecture skill for Discord.js and Pycord covering gateway intents, slash commands, interactive components, rate limiting, and sharding. Use for building or hardening production Discord bots needing correct interaction handling, intents, rate limiting, or sharding.

What it does

This skill covers building production-ready Discord bots in both Discord.js (JavaScript) and Pycord (Python), spanning gateway intents, slash commands, interactive components, rate limiting, and sharding. Its core principles: prefer slash commands over message parsing since the Message Content intent is being deprecated, always acknowledge interactions within 3 seconds, request only the intents actually needed (minimize privileged intents), handle rate limits gracefully with exponential backoff, plan for sharding from the start (required at 2500+ guilds), use interactive components (buttons, selects, modals) for rich UX, and test with guild-scoped commands before deploying globally.

Its patterns cover Discord.js v14 and Pycord bot foundations (client setup, intent configuration, slash command registration, cog/command loading); an interactive components pattern for buttons, select menus, and modals in both frameworks, including component-count and character limits; a deferred response pattern (interaction.deferReply()/ctx.defer()) for slow operations, with a 15-minute follow-up window after acknowledgment; an embed builder pattern with field/character limits; a rate limit handling pattern (Pycord/discord.py handle rate limits automatically, with a documented pattern for custom handling); and a sharding pattern (Pycord's AutoShardedBot handling sharding automatically, plus a scaling guide for getting guilds per shard).

Its sharp edges section documents critical failure modes with fixes: the interaction timeout / 3-second rule (CRITICAL - Discord requires all interactions - slash commands, button clicks, select menus, context menu commands - to be acknowledged within 3 seconds or the user sees "This interaction failed," even if the bot's slow operation succeeds afterward; fixed by deferring immediately, then processing and editing the deferred reply within the 15-minute follow-up window); missing privileged intent configuration (CRITICAL - member/presence/message-content data requires both Developer Portal enablement and code-level intent requests, with a recommendation to avoid the Message Content intent where possible); command registration rate limiting (deploying commands on every startup or in a loop hits rate limits - fixed with a separate deploy script and bulk registration instead of syncing on the ready event); bot token exposure (never hardcode tokens, use .gitignore and environment variables, and know the remediation steps if a token leaks); missing applications.commands OAuth scope (fixed by generating the correct invite URL and re-inviting without kicking the bot); global commands not appearing immediately (Discord propagates global command updates slowly - use guild commands in development and deploy global commands during off-peak in production); frequent gateway disconnections (never block the event loop, handle reconnections gracefully, implement sharding at scale); and modals must be the first response to an interaction (show the modal immediately rather than deferring first, unless a prior check is genuinely needed).

Its validation checks flag: hardcoded Discord tokens (ERROR), tokens assigned from string literals instead of environment variables (ERROR), tokens exposed in client-side code (ERROR), slow operations without a defer call (WARNING - risks interaction timeout), interactions without try/catch error handling (WARNING), use of the privileged Message Content intent where slash commands would suffice (WARNING), requesting all intents rather than only what's needed (WARNING), syncing commands on every bot startup (WARNING), registering commands in a loop instead of bulk (WARNING), and bulk operations without rate limit handling (INFO).

Its collaboration section delegates to other skills: llm-architect for AI-powered conversational bots, slack-bot-builder for cross-platform bot architecture, voice-agents for Discord voice channel integration, postgres-wizard for storing user/server/moderation data, workflow-automation for event-triggered workflows, devops for sharding/scaling/monitoring at scale, and stripe-specialist for premium feature subscriptions.

// Discord.js - Defer for slow operations
module.exports = {
  async execute(interaction) {
    // DEFER IMMEDIATELY - before any slow operation
    await interaction.deferReply();

    // Now you have 15 minutes
    const result = await slowDatabaseQuery();
    const aiResponse = await callLLM(result);

    // Edit the deferred reply
    await interaction.editReply(`Result: ${aiResponse}`);
  }
};

When to use - and when NOT to

Use this skill when the request clearly matches building or hardening a production Discord bot - gateway intents, slash commands, interactive components, rate limiting, or sharding - in Discord.js or Pycord.

Inputs and outputs

Inputs: a Discord bot requirement in Discord.js or Pycord - a slash command, interactive component, rate-limit-safe operation, or scaling need.

Outputs: a production-ready bot implementation with correctly deferred interactions, minimal privileged intents, bulk command registration via a separate deploy script, secure token handling, and sharding configured if needed at scale.

Integrations

Discord.js v14, Pycord (discord.py), Discord Gateway API, Discord Developer Portal. Related skills: llm-architect, slack-bot-builder, voice-agents, postgres-wizard, workflow-automation, devops, stripe-specialist.

Who it's for

Developers building production-ready Discord bots in Discord.js or Pycord who need correct interaction handling, intent minimization, rate limiting, and sharding for scale.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.