Skip to content

Commit

Permalink
docs: update README to CommandGroup vs Commands (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
roziscoding authored Aug 17, 2024
1 parent 5914943 commit e3e8426
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ The main functionality of this plugin is to define your commands, localize them,

```typescript
import { Bot } from "grammy";
import { Commands } from "@grammyjs/commands";
import { CommandGroup } from "@grammyjs/commands";

const bot = new Bot("<telegram token>");

const myCommands = new Commands();
const myCommands = new CommandGroup();

myCommands.command("start", "Initializes bot configuration")
.localize("pt", "start", "Inicializa as configurações do bot")
Expand Down Expand Up @@ -52,15 +52,15 @@ commands flavor and the plugin itself, like so:

```typescript
import { Bot, Context } from "grammy";
import { Commands, commands, CommandsFlavor } from "@grammyjs/commands";
import { CommandGroup, commands, CommandsFlavor } from "@grammyjs/commands";

type BotContext = CommandsFlavor;

const bot = new Bot<BotContext>("<telegram_token>");
bot.use(commands());

bot.on("message", async (ctx) => {
const cmds = new Commands();
const cmds = new CommandGroup();

cmds.command("start", "Initializes bot configuration")
.localize("pt", "start", "Inicializa as configurações do bot");
Expand Down
10 changes: 5 additions & 5 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ The main functionality of this plugin is to define your commands, localize them,

```typescript
import { Bot } from "grammy";
import { Commands } from "@grammyjs/commands";
import { CommandGroup } from "@grammyjs/commands";

const bot = new Bot("<telegram token>");

const myCommands = new Commands();
const myCommands = new CommandGroup();

myCommands.command("start", "Initializes bot configuration")
.localize("pt", "start", "Inicializa as configurações do bot")
Expand All @@ -42,7 +42,7 @@ bot.use(myCommands);
bot.start();
```

It is very important that you call `bot.use` with your instance of the `Commands` class. Otherwise, the command handlers
It is very important that you call `bot.use` with your instance of the `CommandGroup` class. Otherwise, the command handlers
will not be registered, and your bot will not respond to those commands.

### Context shortcuts
Expand All @@ -52,15 +52,15 @@ commands flavor and the plugin itself, like so:

```typescript
import { Bot, Context } from "grammy";
import { Commands, commands, CommandsFlavor } from "@grammyjs/commands";
import { CommandGroup, commands, CommandsFlavor } from "@grammyjs/commands";

type BotContext = CommandsFlavor;

const bot = new Bot<BotContext>("<telegram_token>");
bot.use(commands());

bot.on("message", async (ctx) => {
const cmds = new Commands();
const cmds = new CommandGroup();

cmds.command("start", "Initializes bot configuration")
.localize("pt", "start", "Inicializa as configurações do bot");
Expand Down

0 comments on commit e3e8426

Please sign in to comment.