Construir um plugin
A referência completa do SDK para desenvolvedores de plugins — Python em sandbox, distribuído como zip, disponibilizado através do marketplace.
Plugins são processos Python em sandbox. Escreva um handler, declare suas capacidades, envie um zip — executamos em um container Docker bloqueado e transmitimos eventos do Discord para ele via JSON-RPC.
O que é um plugin?
Um plugin é um pequeno programa que ouve eventos em um servidor Discord e reage a eles.
- Alguém entra em seu servidor → seu plugin envia uma mensagem de boas-vindas.
- Alguém digita
/leaderboard→ seu plugin responde com os 10 melhores usuários. - Someone reacts to a message → your plugin counts the vote and updates the tally.
Você escreve Python. Você importa o SDK. Você decora uma função com @plugin.on_event("member_join") e escreve o que deve acontecer. A plataforma cuida do resto.
O que a plataforma faz por você
- Conecta ao Discord. Você nunca lida com gateways WebSocket, sharding, intents ou limites de taxa. A plataforma entrega eventos aos seus manipuladores e transforma seus valores de retorno em chamadas da API Discord.
- Hospeda seu código. Nenhum servidor para alugar, nenhum Docker para gerenciar, nenhuma implantação às 2 AM. Envie seu código — a plataforma o executa em uma sandbox isolada.
- Talks to the outside world. Call external APIs with
ctx.http, hold live connections open withctx.wsand let the platform inject API keys from encrypted secrets so your code never touches them. See Outbound HTTP. - Processa pagamentos. Set a price or ship it free. Customers pay through Stripe and you keep 70–85% of revenue (tier depends on your last 30 days of volume), paid out to your bank automatically after a hold period. See Selling your plugin.
- Escalabilidade para você. Uma instalação ou um milhão — a plataforma lida com concorrência, tentativas, quotas.
O que você faz
Escreva a lógica que transforma eventos do Discord em ações. É isso. O fluxo fica assim:
┌─────────────────┐ ┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ Discord event │────▶│ YourBot │────▶│ Your plugin's │────▶│ YourBot │
│ (msg, /cmd…) │ │ gateway │ │ handler │ │ sends to │
│ │ │ │ │ │ │ Discord │
└─────────────────┘ └──────────────────┘ └──────────────────┘ └──────────────────┘
▲
│
you write this part
Como um plugin é diferente de um "framework de bot Discord"
| Preocupação | Plugin (esta plataforma) | Bot auto-hospedado (discord.py, etc.) |
|---|---|---|
| Conectar ao Discord | A plataforma faz | Você faz |
| Servidor para hospedar código | A plataforma fornece | Você aluga / gerencia |
| Pagamentos / Stripe | Plataforma cuida | Você constrói você mesmo |
| Instalação por cliente | Um clique para o cliente | Você guia cada cliente pelo OAuth |
| Dimensionamento / cotas / tentativas | Plataforma cuida | Você cuida |
| Avaliações / descoberta | Marketplace integrado | Você comercializa seu bot você mesmo |
| Superfície da API do Discord | Capacidade com restrição (declare o que você precisa) | Acesso completo (sua responsabilidade) |
Onde você gastará seu tempo
- Conectando eventos a handlers. Decoradores como
@plugin.on_event("message_create")ou@plugin.on_slash_command("hello"). - Armazenando estado. Per-server settings, counters and leaderboards live in
ctx.kv(key-value, every plugin has it) orctx.sql(full SQL, a capability you request that is granted after staff review). Either way there is no database to manage. - (Opcional) Uma página de configurações. Solte um manifesto JSON e os clientes recebem uma página de painel que podem configurar seu plugin. Nenhum código frontend necessário.
You can build and submit your first plugin in an afternoon. New developers' first versions go through a short staff review before they appear in the marketplace; established developers publish instantly. Click "Getting started" above when you're ready to write code. Prefer not to start from a blank file? The Plugin Builder writes a working first draft from a description, and the yourbot CLI runs it locally before you upload anything.
Good to know before you build
- Your code has no direct network access. All HTTP goes through
ctx.httpto domains you declare; live connections go throughctx.ws. - Nothing persists on disk. Containers are wiped between restarts. Durable state belongs in
ctx.kvorctx.sql. - Resources are capped. 64 MB memory and a fraction of a vCPU per worker. The full numbers live in Limits and quotas.
- Timers do not run on their own. Marketplace plugins are event-driven: periodic work rides on event traffic with a cooldown. See Pool mode.
- Reading what people type is a privacy capability. Message text arrives empty unless you request
events:message_contentand the server approves it. See the capability catalog. - Your first version is reviewed by a human. Plan for a short wait before it goes live. See Publish & review.
FAQ existente
Jump straight to the section that answers your question. The filter box above only searches the tab you are on.
| I want to… | Vá para o |
|---|---|
| React when someone joins, posts or clicks | Todos os eventos |
| comando de barra | Comandos de barra |
| Novas mensagens | events:message_content |
| Store per-server settings or counters | Armazenamento de chave-valor |
| Keep an API key without hardcoding it | Usuários com direitos |
| Run real SQL queries | Storage & I/O: Sandboxed SQL |
| Call an external API | Mock de HTTP de saída |
| Hold a live connection to a game server | Storage & I/O: WebSockets |
| Do something on a schedule | Cronogramas Cron |
| Exibir configurações | Manifesto do Painel (JSON) |
| Test my plugin before uploading | Começar |
| See what my plugin is allowed to touch | Reference: Capability catalog |
| Check every size and rate limit | Reference: Limits and quotas |
| Deletar Plugin | Nomeie seu plugin |
| Publicar & revisar | Publicar & revisar |
SDK v0.8.4 · Última atualização em julho de 2026 · Voltar ao Dev Portal