Reputation: 233
I have this piece of code but I am not entirely sure on how the bot will wait for 3 seconds before it edit its mesaage.
message.channel.send("Test").then((msg) => {
msg.edit("test1")
msg.edit("test2")
});
Upvotes: 1
Views: 860
Reputation: 827
In JavaScript there are two main functions involving time. Being setTimeout
and setInterval
. setTimeout
allows a specified function to be invoked after a set time, which is what I believe you are trying to do. setInterval
invokes a function repetitively every n
milliseconds specified. If you wanted the bot the wait for 3 seconds before it edits the message to "test2",
message.channel.send("Test").then((msg) => {
msg.edit("test1")
setTimeout(msg.edit("test2"), 3*1000); // 3secs as 3*1000 as it's in milliseconds
})
This code will result in the bot sending a message "Test", instantly editing it to "test1" and 3 seconds later to "test2".
Upvotes: 4