Skip to content

getMyCommands

Use this method to get the current list of the bot's commands for the given scope and user language. Returns an Array of BotCommand objects. If commands aren't set, an empty list is returned.

Parameters

scopeBotCommandScopeOptional
A JSON-serialized object, describing scope of users. Defaults to BotCommandScopeDefault.
language_codeStringOptional
A two-letter ISO 639-1 language code or an empty string

Returns

On success, an array of BotCommand objects is returned.

GramIO Usage

ts
// Get the bot's default commands (all users, all chats)
const 
commands
= await
bot
.
api
.
getMyCommands
({});
console
.
log
(
commands
); // [] if no default commands are set
ts
// Get commands scoped to private chats only
const 
privateCommands
= await
bot
.
api
.
getMyCommands
({
scope
: {
type
: "all_private_chats" },
}); // Get commands for all group chat administrators const
adminCommands
= await
bot
.
api
.
getMyCommands
({
scope
: {
type
: "all_chat_administrators" },
});
ts
// Get localized commands for a specific language
const 
ruCommands
= await
bot
.
api
.
getMyCommands
({
scope
: {
type
: "default" },
language_code
: "ru",
}); const
enCommands
= await
bot
.
api
.
getMyCommands
({
scope
: {
type
: "default" },
language_code
: "en",
});
console
.
log
("RU:",
ruCommands
);
console
.
log
("EN:",
enCommands
);
ts
// Get commands for a specific user in a specific chat
const 
userCommands
= await
bot
.
api
.
getMyCommands
({
scope
: {
type
: "chat_member",
chat_id
: -1001234567890,
user_id
: 987654321,
},
language_code
: "en",
}); // Display the command list for (const
cmd
of
userCommands
) {
console
.
log
(`/${
cmd
.
command
} — ${
cmd
.
description
}`);
}
ts
// Audit all scopes by checking a few key ones
const [
defaults
,
groups
,
privateChats
] = await
Promise
.
all
([
bot
.
api
.
getMyCommands
({}),
bot
.
api
.
getMyCommands
({
scope
: {
type
: "all_group_chats" } }),
bot
.
api
.
getMyCommands
({
scope
: {
type
: "all_private_chats" } }),
]);
console
.
log
("Default:",
defaults
.
map
((
c
) =>
c
.
command
));
console
.
log
("Groups: ",
groups
.
map
((
c
) =>
c
.
command
));
console
.
log
("Private:",
privateChats
.
map
((
c
) =>
c
.
command
));

Errors

CodeErrorCause
400Bad Request: SCOPE_UNSUPPORTEDscope.type is not a valid value — use one of the documented BotCommandScope types
429Too Many Requests: retry after NRate limit hit — check retry_after, use the auto-retry plugin

Tips & Gotchas

  • Both parameters are optional. Omitting scope defaults to { type: "default" }; omitting language_code defaults to an empty string (language-agnostic fallback commands).
  • Returns empty array if no commands are set. This is not an error — it simply means setMyCommands has never been called for that scope/language combination.
  • Scope resolution is hierarchical. Telegram shows the most specific command set that matches the user's context. If chat_member scope has commands, those override all_group_chats, which overrides default. getMyCommands reads one specific scope — it does not simulate the resolution chain.
  • Language overrides the base scope. If you set English commands for the default scope, getMyCommands({ language_code: "en" }) returns those. Users with a different language fall back to the language-agnostic version.
  • language_code must be ISO 639-1 (e.g., "en", "ru", "de"). An empty string "" reads the commands without a language filter.
  • Up to 100 commands per scope+language. Each command description is limited to 1–256 characters; command names must be lowercase and match /[a-z0-9_]{1,32}/.

See Also