Bot CommandsBOT-ONLY
Bot Walkthrough 12 of 18
Bots can publish a list of commands that Telegram shows to users.
Setting Commands
Use setMyCommands with 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
Pass a scope to show a command list only to specific audiences or in specific chats. This example sets a command for group administrators.
await client.setMyCommands(
[{ command: "settings", description: "Manage this chat" }],
{ scope: { type: "allChatAdministrators" } },
);
Pass languageCode to set a localized command list.
await client.setMyCommands(
[{ command: "help", description: "Показать справку" }],
{ languageCode: "ru" },
);
Reading and Deleting Commands
Use getMyCommands to read a command list and deleteMyCommands to delete it.
const commands = await client.getMyCommands();
await client.deleteMyCommands();