Skip to content

discord.js Editing a message and sleeping

So I am very new to discord.js and wanted to know how I can edit a message and then sleep and then edit the message again so it doesn’t cause extremely fast edits. I found this code and couldn’t figure out what to do"Beep").then((sentMessage) => sentMessage.edit("Boop!"))


As suggested by LercDsgn in the comments, you can use setTimeout to edit the message after a certain amount of time.

setTimeout syntax:

setTimeout(function[, delay, arg1, arg2, ...]);
setTimeout(function[, delay]);
setTimeout(code[, delay]);

Note that the delay is in ms. (3000ms = 3 seconds)'Beep!').then(sentMessage => {
    setTimeout(() => {
    }, 3000);