I'm making something for a discord bot and i cant figure out this part...
Discord a chat application where you can make servers and channels for people to talk in, there are also bots and that's what i'm making.
The basic idea is i write a command and the bot denies everyone the permission to talk in the chat, the count down starts and when the count down reaches 0 the bot allows talking again, yes this is a JoJo reference. I have all the allowing and denying ready, just need this countdown to work.
My problem is i cant make my code wait for itself.
//some other code
console.log("Toki uo tomare!")
var x = 0;
function go() {
console.log(x)
if (x++ < 5) {
setTimeout(go, 500);
}
}
go();
console.log("Toki wa ugokidasu...")
//some other code
I expected to see
Toki uo tomare!
0
1
2
3
4
5
Toki wa ugokidasu...
But I saw this instead
Toki uo tomare!
0
Toki wa ugokidasu...
1
2
3
4
5