Answer the question
In order to leave comments, you need to log in
Why is the editMessageText function not working?
Hello! Please help me find the error.
So we have the ban function. It works, but for some reason it doesn't want editMessageText to work.
The error is TelegramError: ETELEGRAM: 400 Bad Request: there is no text in the message to edit.
module.exports = async function(bot, message, query) {
let ban = await Ban.findOne({
where: {
chat_id: query.data.split("_")[1]
}
});
if(ban) {
console.log(`Пользователь уже в бане`);
return;
}
else {
if (query.data.startsWith("ban")) {
let ban = await Ban.create({
chat_id: query.data.split("_")[1],
unban: 3e15
});
if (ban) {
console.log(`Пользователь undefined забанен вручную`);
await bot.sendMessage(ban.chat_id, "Вы заблокированы в боте.");
await bot.editMessageText("Пользователь заблокирован", {
chat_id: message.chat.id,
message_id: message.message_id
});
}
}
}
module.exports = async function(bot, message, query) {
if (query.data.startsWith("unban")) {
let ban = await Ban.findOne({
where: {
chat_id: query.data.split("_")[1]
}
});
if (ban) {
console.log(`Пользователь undefined разблокирован`);
await ban.destroy();
await bot.sendMessage(ban.chat_id, "Вы разблокированы в боте!");
await bot.editMessageText("Пользователь разблокирован", {
chat_id: message.chat.id,
message_id: message.message_id
});
}
}
}
Answer the question
In order to leave comments, you need to log in
You have a check if ban return, and then else and in it again if ban, when the user's BAN script enters the first if does console.log(`The user is already in the ban`); and return; the function will no longer work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question