I am getting error from the server for delete function
See original GitHub issueI have just created a bot in telegraf for deleting the contact and give a temporary message. Unfortunately there is some error while running it.
bot.on('contact', preventContacts);
const preventContacts = async (ctx, next) => {
const { from, contact } = ctx.message;
// Delete contact
await ctx.deleteMessage();
// Give temporary message
const { message_id } = await ctx.replyWithMarkdown(`Hi [${from.first_name||''} ${from.last_name||''}](tg://user?id=${from.id}) you put *${contact.first_name || ''} ${contact.last_name||''}*'s number which is not allowed in group please delete`);
// Delete temporary message
setTimeout(() => ctx.deleteMessage(message_id), 5 * 60 * 1000);
};
It seems to be the message deleted already and therefore getting error. Any one has clue how to fix it ?
Error: 400: Bad Request: message can't be deleted
at buildConfig.then.then.then.then (/Users/mymac/Work/bots/what-to-eat/node_modules/telegraf/core/network/client.js:254:17)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
Failed to process updates. { Error: 400: Bad Request: message can't be deleted
at buildConfig.then.then.then.then (/Users/mymac/Work/bots/what-to-eat/node_modules/telegraf/core/network/client.js:254:17)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
code: 400,
response:
{ ok: false,
error_code: 400, .json yarn.lock
description: 'Bad Request: message can\'t be deleted' },
description: 'Bad Request: message can\'t be deleted',
parameters: {},
on:
{ method: 'deleteMessage',
payload: { chat_id: 407853509, message_id: 567 } } }
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
HTTP error in delete method not working properly
In my fake API, I have just 100 items and the last id is 100 when I put invalid id like 345 I...
Read more >I get the error message "Could not delete from the specified ...
Open the delete query in Design view. · If the query property sheet is not open, press F4 to open it. · Click...
Read more >4 Ways to Solve the Cannot Delete Files Error
Method 1: Force to Delete a File ... If even after several tries, you are repeatedly falling in deletion of a file or...
Read more >Delete data from Cloud Firestore - Firebase
Delete documents. To delete a document, use the delete() method: ... If you need to delete entire collections, do so only from a...
Read more >DELETE - HTTP - MDN Web Docs
The HTTP DELETE request method deletes the specified resource.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Piterden Finally I have found a solution to know where the bot can delete or not in the group
const deleteJoinMessage = await ctx.deleteMessage().then((response) => response, ({ response }) => response.ok)
Please have a look and update you opinion
I think next would work correct only inside
.use()
methods, which called middlewares. But I can make a mistake, and you better to check it out.