You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all, probably is a problem with my entry level of Javascript. I made a module with a sample code for webhook bot:
constTelegramBot=require('telebot');constbot=newTelegramBot({token: process.env.TELEGRAM_BOT_TOKEN});bot.on('text',msg=>bot.sendMessage(msg.from.id,msg.text));bot.on('/hello',msg=>msg.reply.test('welcome'));bot.on('edit',(msg)=>{returnmsg.reply.text('I saw it! You edited message!',{asReply: true});});bot.setWebhook(`${process.env.URL}:443`);bot.start();module.exports={ bot }
And then required it in main module:
constTelegramBot=require('telebot');constbot=require('./telegram');constserver=app.listen(port,(err)=>{if(!err){console.log(`App started on ${process.env.URL}:${port}`);if(process.env.TELEGRAM_CHAT_NOTIFICATION)bot.sendMessage(process.env.TELEGRAM_CHAT_NOTIFICATION,`Application deployed and running without errors on ${process.env.URL}.`);}else{console.error(err);}});
But console log me that bot.sendMessage is not a function.
const{ bot, sendMessageTo }=require('./telegram');sendMessageTo(process.env.TELEGRAM_CHAT_NOTIFICATION,`Application deployed and running without errors on ${process.env.URL}.`);
Question
Is this the only solution can be made? There's one better than this?
The text was updated successfully, but these errors were encountered:
I had the same issue with JetBrain's WebStorm IDE. It's simply because the IDE is not smart enough to figure it out. You can disable the inspection for that method to remove the warning.
The developers of telebot could JSDoc the methods such that IDEs figure it out.
bot.sendMessage is not a function
Hi all, probably is a problem with my entry level of Javascript. I made a module with a sample code for webhook bot:
And then required it in main module:
But console log me that bot.sendMessage is not a function.
Solution proposal
The solution I made was to create a new function:
and then call it in main module:
Question
Is this the only solution can be made? There's one better than this?
The text was updated successfully, but these errors were encountered: