Bot goes offline after like a day

I host my discord bot has a file "warn_bot" so I write cd ... then node warn_bot.js the bot works flawlessly but after like 1 day the bot goes offline. I host the bot on my vps, no mess with my vps.
41 Replies
d.js toolkit
d.js toolkit13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
hey.o
hey.o13mo ago
PM2 - Home
Advanced process manager for production Node.js applications. Load balancer, logs facility, startup script, micro service management, at a glance.
Novuz
NovuzOP13mo ago
all i need to type "npm install pm2 -g"? and then "pm2 start app.js"
hey.o
hey.o13mo ago
since your file is warn_bot.js you'd do "pm2 start warn_bot.js" but yeah
Novuz
NovuzOP13mo ago
it is online now?
hey.o
hey.o13mo ago
yeah
Novuz
NovuzOP13mo ago
oh thx!
hey.o
hey.o13mo ago
np
Novuz
NovuzOP13mo ago
I did this on vps, but doesn't seem to work
hey.o
hey.o13mo ago
what vps are you using??
Novuz
NovuzOP13mo ago
a swedish hosting site swehosting now its not working on my pc also
hey.o
hey.o13mo ago
run "pm2 logs" see if you find anything
Novuz
NovuzOP13mo ago
hey.o
hey.o13mo ago
scroll up
Novuz
NovuzOP13mo ago
hey.o
hey.o13mo ago
wait so you're sure that warn_bot.js is your primary file or do you have an app.js file
Novuz
NovuzOP13mo ago
hey.o
hey.o13mo ago
where are your dependencies???
Novuz
NovuzOP13mo ago
didn't need it now its working but the bot is still offline
hey.o
hey.o13mo ago
with 120 restarts wydm didnt need it
Novuz
NovuzOP13mo ago
oh
hey.o
hey.o13mo ago
you need discord.js installed to use it try running npm install discord.js
Novuz
NovuzOP13mo ago
ok
hey.o
hey.o13mo ago
k now start it
Novuz
NovuzOP13mo ago
not working
hey.o
hey.o13mo ago
just start it with node and see if it works because pm2 shouldn't be any different
Novuz
NovuzOP13mo ago
its working
hey.o
hey.o13mo ago
try just running pm2 kill & starting it again
Novuz
NovuzOP13mo ago
hey.o
hey.o13mo ago
mb was doing sth else run it with the --attach flag
Novuz
NovuzOP13mo ago
only type —attach flag?
hey.o
hey.o13mo ago
no like pm2 start [file] --attach
Novuz
NovuzOP13mo ago
Ok thanks will test when I wake up.
zay!
zay!13mo ago
'Cannot find module ...' somewhere in your code is an absolute reference to a file that exists on your home PC but not on your remote VPS. update this file path reference to be relative.
hey.o
hey.o13mo ago
that's just when he tried to start it w "pm2 start warn_bot" without the .js extension i think
zay!
zay!13mo ago
No @hey.o is right, you need dependencies installed so that your remote code can import items just like your code does on your development PC. Your bot file does not come bundelled with everything you need. Oh you might be right, I can't tell which are the VPS terminals and which are the home PC terminals.
hey.o
hey.o13mo ago
i don't think that's the issue anymore since he can run it with node just fine but it errors when he tries with pm2 haha yeah
zay!
zay!13mo ago
I would like to see the logs output from your warn_bot process. Because it crashed instantly I think it's because you're now calling "C:...\warn_bot" which has no file extension so PM2 cannot resolve it; when you call the file with Node you are appending the '.js' which might be why that works.
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
Novuz
NovuzOP13mo ago
So what should I do to fix the problem?
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server