← Documentação  /  Guia do Desenvolvedor

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.

These docs are publicly viewable. To publish a plugin you'll need a free YourBot account: sign in to access the Dev Portal.
SDK v0.8.4

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 with ctx.ws and 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çãoPlugin (esta plataforma)Bot auto-hospedado (discord.py, etc.)
Conectar ao DiscordA plataforma fazVocê faz
Servidor para hospedar códigoA plataforma forneceVocê aluga / gerencia
Pagamentos / StripePlataforma cuidaVocê constrói você mesmo
Instalação por clienteUm clique para o clienteVocê guia cada cliente pelo OAuth
Dimensionamento / cotas / tentativasPlataforma cuidaVocê cuida
Avaliações / descobertaMarketplace integradoVocê comercializa seu bot você mesmo
Superfície da API do DiscordCapacidade com restrição (declare o que você precisa)Acesso completo (sua responsabilidade)

Onde você gastará seu tempo

  1. Conectando eventos a handlers. Decoradores como @plugin.on_event("message_create") ou @plugin.on_slash_command("hello").
  2. Armazenando estado. Per-server settings, counters and leaderboards live in ctx.kv (key-value, every plugin has it) or ctx.sql (full SQL, a capability you request that is granted after staff review). Either way there is no database to manage.
  3. (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.http to domains you declare; live connections go through ctx.ws.
  • Nothing persists on disk. Containers are wiped between restarts. Durable state belongs in ctx.kv or ctx.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_content and 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 clicksTodos os eventos
comando de barraComandos de barra
Novas mensagensevents:message_content
Store per-server settings or countersArmazenamento de chave-valor
Keep an API key without hardcoding itUsuários com direitos
Run real SQL queriesStorage & I/O: Sandboxed SQL
Call an external APIMock de HTTP de saída
Hold a live connection to a game serverStorage & I/O: WebSockets
Do something on a scheduleCronogramas Cron
Exibir configuraçõesManifesto do Painel (JSON)
Test my plugin before uploadingComeçar
See what my plugin is allowed to touchReference: Capability catalog
Check every size and rate limitReference: Limits and quotas
Deletar PluginNomeie seu plugin
Publicar & revisarPublicar & revisar

SDK v0.8.4 · Última atualização em julho de 2026 · Voltar ao Dev Portal