command method

Bot<CTX> command(
  1. String command,
  2. UpdateHandler<CTX> handler, {
  3. bool caseSensitive = false,
})

Adds a handler for a specific command.

Parameters:

  • command: The command name (without leading slash)
  • handler: The handler function
  • caseSensitive: Whether command matching is case sensitive

Example:

bot.command('start', (ctx) async {
  await ctx.reply('Welcome! 👋');
});

bot.command('Help', (ctx) async {
  await ctx.reply('Available commands: /start, /help');
}, caseSensitive: true);

Implementation

Bot<CTX> command(
  String command,
  UpdateHandler<CTX> handler, {
  bool caseSensitive = false,
}) {
  return on(
    CommandFilter<CTX>(command, caseSensitive: caseSensitive),
    handler,
  );
}