node.jstelegram

Telegram bot error, 409 ETELEGRAM CONFLICT: terminated by other getUpdates request


I am trying to make a Telegram bot using Node.js with node-telegram-bot-api in pterodactyl panel, but I keep getting the error:

"error: [polling_error] {"code":"ETELEGRAM","message":"ETELEGRAM: 409 Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}"

This is my code:

process.env.NTBA_FIX_319 = 1
require('./settings.js')
const TelegramBot = require('node-telegram-bot-api');
const CFonts = require('cfonts');
const chalk = require('chalk')
const axios = require('axios');
const fs = require('fs');
const path = require('path');

//ON START
const bot = new TelegramBot(botkey, {
    polling: true
});
console.log(chalk.red(`BOT TELEGRAM IS ACTIVE`))
bot.sendMessage(ownerid, `BOT ACTIVE`)

//MAIN
bot.onText(/\/start/, (msg, match) => {
    const chatId = msg.chat.id;
    bot.sendMessage(chatId, `Hello! I am Leonn, a BOT made by Raeonn to process in-game recharges!\nYour Telegram ID is : ${chatId}\nMessage Raeonn to get verified.`);
});


let file = require.resolve(__filename)
fs.watchFile(file, () => {
fs.unwatchFile(file)
console.log(chalk.blue(`Update ${__filename}`))
delete require.cache[file]
require(file)    
})

Solution

  • Double check that you didn't run the file twice. For example, remove the watchFile which may prevent fully restarting.