Skip to content

Handling Commands

Alper Kürşat edited this page Feb 14, 2022 · 2 revisions

There's a built-in middleware for handling commands from user of your bots.

import Botocrat, {Commands} from "@botocrat/core"

new Botocrat()
  .use(Commands({
    start(req, res){
      res.send("Congratulations! You started the bot.")
    }
    help(req, res){
      res.reply("How can I help you?")
    }
  }))

Commands also short-circuits the middleware chain. That means, if user called a command, you can't get message via .get("message", ...) method.

Clone this wiki locally