yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.35k stars 1.52k forks source link

TypeError: bot.getChatMembersCount is not a function #1049

Closed vhforbes closed 11 months ago

vhforbes commented 1 year ago

I'm trying to get the number of members using getChatMembersCount

I'm getting a typeError saying that "bot.getChatMembersCount is not a function"

image

This is my first issue on github, overall I'm really enjoying the bot, if it is my mistake, I would be really glad if someone can point it out!

Really appreciate.

VDS13 commented 1 year ago

I'm trying to get the number of members using getChatMembersCount

I'm getting a typeError saying that "bot.getChatMembersCount is not a function"

image

This is my first issue on github, overall I'm really enjoying the bot, if it is my mistake, I would be really glad if someone can point it out!

Really appreciate.

The function is called getChatMemberCount, not getChatMembersCount.

vhforbes commented 1 year ago

Ok, the function works now! But after reviewing the @types of the package, it explicitly says:

getChatMembersCount(chatId: TelegramBot.ChatId): Promise<number>;

So typescript throws a error because the typing is wrong when using it in the singular: getChatMemberCount.

danielperez9430 commented 1 year ago

Yep, we talk about this some days ago in the telegram group, the method is getChatMemberCount, not plural. But someone that do the types in the Types repo put the name wrong

VDS13 commented 1 year ago

Ok, the function works now! But after reviewing the @types of the package, it explicitly says:

getChatMembersCount(chatId: TelegramBot.ChatId): Promise<number>;

So typescript throws a error because the typing is wrong when using it in the singular: getChatMemberCount.

https://github.com/DefinitelyTyped/DefinitelyTyped/pull/64271