nodegin / tglib

TDLib (Telegram Database library) bindings for Node.js
114 stars 16 forks source link

Problem with getSupergroupMembers #45

Closed mortezae closed 5 years ago

mortezae commented 5 years ago

the command getSupergroupMembers and many other getSupergroup* don't work for me. It gives no details in error messages, just "Query timed out after 30 seconds." I googled a lot about tdlib + getSupergroupMembers to find probable simillar problem but it seems nobody else had this problem before me. Also I checked sample codes from other languages and found no mistake in my code. Here it is:

let chatMembers = await client.fetch({
      '@type': 'getSupergroupMembers',
      'supergroup_id': -1001304740402,
      'filter': null,
      'offset': 0,
      'limit': 20
    })

I'm using TDLib 1.3 on Linux. I updated tglib from 2.x to 3.0.1 but there in no difference.

mortezae commented 5 years ago

Just noticed that if I use this supergroup id in getChat command instead of getSupergroupMembers , then I get:

{ '@type': 'chat',
  id: -1001304740402,
  type:
   { '@type': 'chatTypeSupergroup',
     supergroup_id: 1304740402,
     is_channel: false },
  title: 'My SuperGroup',
  ...
}

As you see chat.id lacks the -100 prefix that supergroup_id owns. Then I removed the prefix in my code snippet (getSupergroupMembers) and this time I got this error:

'{"@type":"error","code":6,"message":"Supergroup not found"}'
mortezae commented 5 years ago

So I can use this:

    let chatMembers = await client.fetch({
      '@type': 'searchChatMembers',
      'chat_id': chat,
      'filter': null,
      'limit': 20,
    })

and I do for now. But still don't know whats wrong with supergroup commands.

mortezae commented 5 years ago

It was my mistake, in getSupergroupMembers documentation it is explicitly clarified that:

Can be used only if SupergroupFullInfo.can_get_members == true; additionally, administrator privileges may be required for some filters.

nodegin commented 5 years ago

@mortezae Nice find