yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.45k stars 1.53k forks source link

How to use promote chat member #874

Closed clintgallivan closed 3 years ago

clintgallivan commented 3 years ago

I am trying to use the method (promoteChatMember) but I get back error: [polling_error] {}

Here is my code

bot.on("message", (msg) => {
  const chatId = msg.chat.id;
  const userId = msg.from.id;
  if (msg.text.includes("hi")) {
    bot.sendMessage(chatId, `Hello ${userId}`);
    bot.promoteChatMember(chatId, userId, false, true);
    console.log(userId);
  }
});

here is the telegram API docs: https://core.telegram.org/bots/api#promotechatmember

go to "promoteChatMember" for the method.

Thank you!!!

danielperez9430 commented 3 years ago

Hi mate, Here is an example of use, the tutorial is in Spanish but you can easily translate it.

https://tecnonucleous.com/2020/05/27/como-cambiar-el-titulo-custom-de-administrador-de-un-usuario-mediante-un-bot/

abhint commented 3 years ago
bot.onText(/\/hi/, function onLoveText(msg) {
  bot.sendMessage(msg.chat.id, "Hello, World!");
});

https://github.com/yagop/node-telegram-bot-api/blob/master/examples/polling.js