My Discord Bot doesn't run outside the console

Hi,

So I have recently been working on a discord bot (https://glitch.com/~vortexthe-god) , and although it runs in console, it doesn’t run automatically outside it.

Here, it says I may have nothing running on my port. However, stayOnline.js should be doing that for me.

Hi @xetrov05, welcome to the Glitch forum!

Your bot’s currently not running because a) you have an error in your package.json, probably the trailing comma at https://glitch.com/edit/#!/vortexthe-god?path=package.json:13:25 and b) because your package.json is telling Glitch to run server.js but there’s no such file. You probably want to tell Glitch to run bot.js at https://glitch.com/edit/#!/vortexthe-god?path=package.json:10:19.

It also looks like you haven’t added the discord.js package to your package.json file, so you’ll probably need to do that as well.

Lastly, the solution you have in place in https://glitch.com/edit/#!/vortexthe-god?path=stayOnline.js:1:0 will work to keep your bot running until the project is restarted, but once that happens (every 12 hours at least) then your bot won’t automatically wake up again. You’ll need an external service like UptimeRobot or something similar to wake your project up after the twice-daily project stops, and if you set that up correctly then the code block at https://glitch.com/edit/#!/vortexthe-god?path=stayOnline.js:10:0 won’t serve any purpose at all.

Hope this helps!

Hey there! So I have tried your solution. I have added discord.js and enmap to the project. However, fs says that this package name is not currently in use. What should I do? Is that the only thing that is stopping the code from running correctly?

The first thing I would work towards is making your package.json valid so that Glitch can run your project. http://package-json-validator.com/ can help with that.

Once you have a working package.json file if there are additional problems they’ll likely show up in the logs and you can work through those one at a time.

I now get this error: cannot find module discord.js . I think it’s something to do with the package.json file, but I’m not too sure.