Skip to content
GitHub

MeoCord: Decorator-based Discord bot framework for TypeScript

Built on discord.js, with the pipeline you’d build yourself · 4.2

One call, through the pipeline

src/home/pipeline.slash.controller.ts
@Command('greet', CommandType.SLASH)
@Defer()
@UseGuard(MemberGuard)
@UseInterceptor(TraceInterceptor)
@UsePipe('name', TrimPipe)
async greet(interaction: ChatInputCommandInteraction, { name }: { name: string }) {
  await respond(interaction).send({ content: `Hello, ${name}!` })
}
# general
adaused /greet
/greet name: Ada
greeterAPP
greeter is thinking…
greeterAPP
Hello, Ada!
greeterAPP
Only you can see this
This command is for members.

Trace

Recorded from a real run of this code, at build time

  1. @Deferdeferreddeferred
  2. MemberGuardalloweddenied
  3. TraceInterceptorbeforenot reached
  4. TrimPipe" Ada " → "Ada"not reached
  5. greet()greets "Ada"not reached
  6. TraceInterceptorafternot reached
  7. respond()Hello, Ada!not reached

respond() edits the deferred reply: one call, whatever the state.

Why MeoCord

  • One pipeline, every call.

    Guards, interceptors, validation, cooldowns and exception filters run in a fixed order around each handler they apply to.

    See how
  • One call answers Discord.

    respond() tracks each answer as unanswered, deferred or replied, and makes the call Discord expects: reply, update, edit or follow-up.

    See how
  • Checked by the compiler.

    A handler whose params don't fit its route or pattern fails to compile, and so does a catalog key the default catalog lacks.

    See how
  • Tested as it runs.

    invoke and dispatch run a handler through the bot's own pipeline, with mocks of discord.js's own classes.

    See how

What you can build

Where to go next

Learn

The Guide, in reading order: what a bot is made of, each kind of handler, the pipeline around it, testing and shipping.

  1. Create a bot. The CLI asks which package manager to use.

    npx meocord create my-bot
    bunx meocord create my-bot
    pnpm dlx meocord create my-bot
    yarn dlx meocord create my-bot
  2. Give it its token, in .env beside meocord.config.ts.

    .env
    DISCORD_TOKEN=your-bot-token
  3. Run it, rebuilding as you save.

    npx meocord start --dev
    bunx meocord start --dev
    pnpm exec meocord start --dev
    yarn meocord start --dev

Look up

Every public symbol, by kind, with its types and examples, and every CLI command with its options.

Migrate or compare

Moving to 4.2 from an earlier MeoCord, or to MeoCord from another framework.