I have a file structure like this:
bots -|
|- test1 -|
|- index.js
|- activate.bat
|- token.txt
|- test2 -|
|- index.js
|- actiate.js
|- token.txt
|- run_all.bat
index.js are files to be run be NodeJS with the node command. Both index.js files require a key that is stored in token.txt file. The index.js file reads the text file
activate.bat is simply this:
@echo off
node index.js
However I want to run both at once, and by only starting one .bat file, this is where run_all.bat comes in.
I have tried to run each file like I ran in activate.bat so:
@echo off
echo Starting all bots...
start /b node test1\index.js
start /b node test2\index.js
However I get an error:
PS C:\Users\Simon\Desktop\bot> ./run_all.bat
Starting all bots...
PS C:\Users\Simon\Desktop\bot> test1 running
test2 running
(node:10176) UnhandledPromiseRejectionWarning: Error: An invalid token was provided.
at Promise (C:\Users\Simon\node_modules\discord.js\src\client\rest\RESTMethods.js:34:54)
at new Promise (<anonymous>)
at RESTMethods.login (C:\Users\Simon\node_modules\discord.js\src\client\rest\RESTMethods.js:33:12)
at Client.login (C:\Users\Simon\node_modules\discord.js\src\client\Client.js:279:30)
at ReadFileContext.callback (C:\Users\Simon\Desktop\bot\test1\index1.1.js:88:12)
at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:235:13)
(node:4836) UnhandledPromiseRejectionWarning: Error: An invalid token was provided.
at Promise (C:\Users\Simon\node_modules\discord.js\src\client\rest\RESTMethods.js:34:54)
at new Promise (<anonymous>)
at RESTMethods.login (C:\Users\Simon\node_modules\discord.js\src\client\rest\RESTMethods.js:33:12)
at Client.login (C:\Users\Simon\node_modules\discord.js\src\client\Client.js:279:30)
at ReadFileContext.callback (C:\Users\Simon\Desktop\bot\test2\index.js:65:12)
at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:235:13)
(node:10176) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:4836) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:10176) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:4836) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
When run each activate.bat alone I do not get this error, what is going wrong? Are my batch commands somehow mixing up the different token.txt files