Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if a message is edited?

I am intending for my bot to allow only "ew" to be sent in chat. I have resolved majority of the work-arounds, however, there is one I can't resolve independently. When someone posts "ew" in chat and then edits the message to something else, it remains like that without being deleted.

How could I resolve this?

like image 278
Brandon Avatar asked Apr 08 '18 07:04

Brandon


People also ask

How can you tell if someone edited a message on discord?

When you click on (edited), you can see the versions of the message who as edited...

Can we see the edited message on telegram?

Edit the message, then click the checkmark button to send the edited message. You will now see the updated message with the “Edited” tag in the chat.


1 Answers

client.on('messageUpdate') should trigger everytime a message (in cache) is edited. I'm pretty sure you will not get the event if the message was sent when the bot was offline. But you could fetch the messages when the bot starts.

client.on('messageUpdate', (oldMessage, newMessage) => {
   if(newMessage.content != "ew"){
       newMessage.delete(); // for example
   }
})
like image 150
André Avatar answered Nov 01 '22 09:11

André