Guides

Bot CommandsBOT-ONLY

Bot Walkthrough 2 of 18

Bots can publish a list of commands that Telegram shows to users.

Setting Commands

setMyCommands accepts each command’s name and description.

await client.setMyCommands([
  { command: "start", description: "Start the bot" },
  { command: "help", description: "Show help" },
]);

This only changes the displayed command list. Register handlers separately with client.command().

Scoping and Localizing Commands

A scope limits a command list to specific audiences or chats. This example sets a command for group administrators.

await client.setMyCommands(
  [{ command: "settings", description: "Manage this chat" }],
  { scope: { type: "allChatAdministrators" } },
);

The languageCode option sets a localized command list.

await client.setMyCommands(
  [{ command: "help", description: "Показать справку" }],
  { languageCode: "ru" },
);

Reading and Deleting Commands

getMyCommands reads a command list, while deleteMyCommands deletes it.

const commands = await client.getMyCommands();
await client.deleteMyCommands();