pyrogram / pyrogram

Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
https://pyrogram.org
GNU Lesser General Public License v3.0
4.39k stars 1.42k forks source link

AttributeError: 'Client' object has no attribute 'set_bot_commands' #714

Closed MrBotDeveloper closed 3 years ago

MrBotDeveloper commented 3 years ago

Checklist

Description

Sir, I am trying to set Bot commands. My code is as follows

from pyrogram import Client

Client.set_bot_commands([
    BotCommand("start","Start the bot")
])
...

But it shows the following error.

Traceback

The full traceback (if applicable).

Traceback (most recent call last):
  File "main.py", line 1, in <module>
  Client.set_bot_commands([
  AttributeError: 'Client' object has no attribute 'set_bot_commands'
jonatan1609 commented 3 years ago

You are supposed to use it with a Client object, not with the class itself but with an object.

jonatan1609 commented 3 years ago

The same code works for me (except importing pyrogram.types for BotCommand). Try to re-install it and make sure you install it to the same environment you ran the code with.

MrBotDeveloper commented 3 years ago

Can you share it's sample code for better understanding ????

jonatan1609 commented 3 years ago

Can you share it's sample code for better understanding ????

Try to re-run the pip install command, and try again. You probably didn't install it to the correct interpreter. Try it out:

python -m pip install https://... etc python script.py

If needed, use python3 instead of python.

MrBotDeveloper commented 3 years ago

Ok sir thanks a lot ......