1616# You should have received a copy of the GNU Lesser General Public License
1717# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818
19- from typing import List , Optional
19+ from typing import List
2020
21+ import pyrogram
2122from pyrogram import raw , types
2223from pyrogram .scaffold import Scaffold
2324
2425
2526class SetBotCommands (Scaffold ):
2627 async def set_bot_commands (
27- self ,
28- commands : Optional [List [types .BotCommand ]],
29- scope : types .BotCommandScope = types .BotCommandScope (
30- types .BotCommandScope .DEFAULT
31- ),
32- lang_code : str = "" ,
28+ self : "pyrogram.Client" ,
29+ commands : List ["types.BotCommand" ],
30+ scope : "types.BotCommandScope" = types .BotCommandScopeDefault (),
31+ language_code : str = "" ,
3332 ):
34- """Set the bot commands list .
33+ """Set the list of the bot's commands.
3534
3635 The commands passed will overwrite any command set previously.
3736 This method can be used by the own bot only.
3837
3938 Parameters:
4039 commands (List of :obj:`~pyrogram.types.BotCommand`):
4140 A list of bot commands.
42- Pass None to remove all commands.
41+ At most 100 commands can be specified.
42+
43+ scope (:obj:`~pyrogram.types.BotCommandScope`, *optional*):
44+ An object describing the scope of users for which the commands are relevant.
45+ Defaults to :obj:`~pyrogram.types.BotCommandScopeDefault`.
46+
47+ language_code (``str``, *optional*):
48+ A two-letter ISO 639-1 language code.
49+ If empty, commands will be applied to all users from the given scope, for whose language there are no
50+ dedicated commands.
4351
4452 Returns:
45- ``bool``: True on success, False otherwise .
53+ ``bool``: On success, True is returned .
4654
4755 Example:
4856 .. code-block:: python
@@ -53,15 +61,12 @@ async def set_bot_commands(
5361 app.set_bot_commands([
5462 BotCommand("start", "Start the bot"),
5563 BotCommand("settings", "Bot settings")])
56-
57- # Remove commands
58- app.set_bot_commands(None)
5964 """
6065
6166 return await self .send (
6267 raw .functions .bots .SetBotCommands (
63- commands = [c .write () for c in commands or [] ],
64- scope = scope .write (),
65- lang_code = lang_code ,
68+ commands = [c .write () for c in commands ],
69+ scope = await scope .write (self ),
70+ lang_code = language_code ,
6671 )
6772 )
0 commit comments