2021-06-26 19:45:06 +03:00
|
|
|
import { TelegramClient } from '../../client'
|
2021-08-05 20:38:24 +03:00
|
|
|
import { tl } from '@mtcute/tl'
|
2021-06-26 19:45:06 +03:00
|
|
|
import { BotCommands } from '../../types'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a list of current bot's commands for the given command scope
|
|
|
|
* and user language. If they are not set, empty set is returned.
|
|
|
|
*
|
|
|
|
* Learn more about scopes in the [Bot API docs](https://core.telegram.org/bots/api#botcommandscope)
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
export async function getMyCommands(
|
|
|
|
this: TelegramClient,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Scope of the commands.
|
|
|
|
*
|
|
|
|
* Defaults to `BotScope.default_` (i.e. `botCommandScopeDefault`)
|
|
|
|
*/
|
|
|
|
scope?: tl.TypeBotCommandScope | BotCommands.IntermediateScope
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User language applied to the scope.
|
|
|
|
*/
|
|
|
|
langCode?: string
|
|
|
|
}
|
|
|
|
): Promise<tl.RawBotCommand[]> {
|
|
|
|
return this.call({
|
|
|
|
_: 'bots.getBotCommands',
|
|
|
|
scope: params?.scope
|
|
|
|
? await this._normalizeCommandScope(params.scope)
|
|
|
|
: {
|
|
|
|
_: 'botCommandScopeDefault',
|
|
|
|
},
|
|
|
|
langCode: params?.langCode ?? '',
|
|
|
|
})
|
|
|
|
}
|