yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.13k stars 1.49k forks source link

banChatMember definition not correct #1102

Closed HRK44 closed 11 months ago

HRK44 commented 11 months ago

packages:

"node-telegram-bot-api": "^0.61.0", "@types/node-telegram-bot-api": "^0.61.6",

I'm using banChatMember like this bot.banChatMember(chatId, parseInt(m, 10), ban) but it gives me some weird error like TypeError: Cannot create property 'chat_id' on number '1689496709' where it's mixing up the ban date and the chatId.

Looking at the function definition on main package:

    * @param  {Number|String} chatId   Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
    * @param  {Number} userId  Unique identifier of the target user
    * @param  {Object} [options] Additional Telegram query options
    * @return {Promise} True on success.
    * @see https://core.telegram.org/bots/api#banchatmember
    */
  banChatMember(chatId, userId, form = {}) {
    form.chat_id = chatId;
    form.user_id = userId;
    return this._request('banChatMember', { form });
  }

but on typescript, gives me this signature:

method) TelegramBot.banChatMember(chatId: NodeTelegramBot.ChatId, userId: number, untilDate?: number | undefined, revokeMessages?: boolean | undefined): Promise<boolean>

which one is not correct? If I remove the ban timer and just call with 2 arguments it works fine

danielperez9430 commented 11 months ago

The correct is: banChatMember(chatId, userId) or if you need to pass the optional params: banChatMember(chatId, userId, { untilDate: XXXXX, revoke_messages: YYYY })