yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.17k stars 1.5k forks source link

TypeError: bot.getChatMembers is not a function #1065

Closed estoylive closed 1 year ago

estoylive commented 1 year ago

i am facing this problem and i have been going in circles, I don't seem to find the solution.

is it possible that there is NO WAY to iterate through a group's members list? even though I am using an admin bot??

how can this be? i even asked chatgpt and it also told me to use:

bot .getChatMembers(chatId) .then((members) => { //your code here }) .catch((error) => { console.error( error); });

But this throws "getChatMembers is not a function". Can it be possible that you guys took this function away??? if so, why would you do that? i am going insane, in fact, I went insane for the past 7 hours trying to look for an alternative.

please guys, how does this work? THERE MUST BE A WAY TO GET ALL USER ID so I can iterate and add or remove permissions.

please help

danielperez9430 commented 1 year ago

The correct command is getChatMember SINGULAR (Don't trush the autocomplete of the editor)

Reference: https://core.telegram.org/bots/api#getchatmember

danielperez9430 commented 1 year ago

And the bots can't get the list of members in the chat. Its a Telegram restriction, so you can store the users that write of similar to the db. And use the events bot.on('...

If your group have more that 10k ->bot.on("chat_member", (msg) => { // Do something }) How to enable: https://github.com/yagop/node-telegram-bot-api/issues/923#issuecomment-996038501

Less that 10k users ->

bot.on('new_chat_members', (msg) => {
  console.log(msg)  
})

In the msg you have the info of the user, so you can store it in the db and know when a new member enter of the left the chat

estoylive commented 1 year ago

oh no... Oh no, you have just confirmed all my fears 😪😥

thanks for giving me closure, though xDDD

so it's all about being creative from this point on