r/JavaScriptTips • u/Asleep-Ad-8717 • May 15 '22
Coding discord bot
Hi, Im very new to javascript only starting a couple weeks ago. I’ve started coding a discord bot and its very annoying having to run the ‘node .’ command. For turning it off I used:
else if (command == ‘shutdown’){ message. channel, send ("Shutting down…").then(() => { client .destroy();
})
}
});
Is there any type of command I could use to undo this command?? to turn it on?
2
u/GaymerWasTaken May 15 '22
Write a bash/batch script that loops indefinitely and waits for a keypress.
Should go something like this on Windows:
loop:
node .
pause
goto loopor this on Linux:
while :
do
node .
read -n 1 k <&1
doneEdit: What I'm trying to say is, this isn't really possible in Javascript. You could, of course, create a handler that will do this for you in Javascript - ie loop the main function, or use a library that will terminate your program and restart it on edit, but other than that the best thing to do is to use bash/batch.
2
u/belkarbitterleaf May 15 '22
Not a lot of context here, but I'm assuming you mean that you have some data generated while the bot is running, and you want the bot to remember it when it starts up again?