I’m encountering an issue while trying to extract all chat IDs from a group and channel using Telethon. Here’s the code snippet I’m using:
@tejas.on(events.NewMessage(outgoing=True, pattern=r'.list'))
async def hello(event):
chat = await event.get_chat()
all_chats = tejas(functions.messages.GetAllChatsRequest(except_ids=[]))
for _, chat in enumerate(all_chats.chats):
print(chat.title)
await tejas.send_message(chat, chat.title)
However, when running this code, I’m getting the following error:
Traceback (most recent call last):
File "C:UsersACERAppDataLocalProgramsPythonPython312Libsite-packagestelethonclientupdates.py", line 570, in _dispatch_update
await callback(event)
File "c:UsersACEROneDriveDesktoptesmain.py", line 12, in hello
all_chats = tejas(functions.messages.GetAllChatsRequest(except_ids=[]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'telethon.tl.functions.messages' has no attribute 'GetAllChatsRequest'. Did you mean: 'GetAllDraftsRequest'?
I’m unsure why this error is occurring, as I believe I’m following the Telethon documentation correctly. Could someone help me understand what might be causing this issue and how to resolve it?
Prm Ytb is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.