I got this bot that I made. Every piece of command works just fine after I deployed it via
git push heroku master
Except this piece of code
const Telegraf = require('telegraf');
const Telegram = require('telegraf/telegram')
const bot = new Telegraf('******');
bot.command(['pin', 'Pin', 'PIN'], function(ctx) {
if (ctx.message.reply_to_message == undefined){
ctx.reply("Asegurate de responder al mensaje que quieras fijar")
}
var chatId = ctx.chat.id;
var fromId = ctx.from.id;
var messageId = ctx.message_id;
var chatype = ctx.chat.type;
var replyFrom = ctx.message.reply_to_message.message_id;
var fromName = ctx.from.username;
const opts = {};
opts.disable_notification = false;
ctx.telegram.getChatMember(chatId, fromId).then(function(data){
if ((data.status == 'creator') || (data.status == 'administrator')){
if (chatype == 'supergroup'){
ctx.telegram.pinChatMessage(chatId, replyFrom);
ctx.deleteMessage();
}
else if (chatype == 'private'){
ctx.telegram.sendMessage(chatId, "Comando solo disponible en supergrupos");
}
else if (chatype == 'group'){
ctx.telegram.sendMessage(chatId, "Comando solo disponible en supergrupos.");
}
}
else {
ctx.telegram.sendMessage(chatId, "Lo siento " + fromName + " no eres administrador");
}
})
});
I have no clue what's causing this problem. The terminal shows no errors and it only works once I bot.launch() it. I have tried re-writting it from scratch, made it differently but nothing works. Every piece of advise and/or comments are helpful. Thanks in advance.