How Do I Get This Discord Bot Created By Discord Bot Maker To Work On Heroku

- 1 answer

so the bot works perfectly when running it localy but when i run it on heroku it gives me a error saying:

2018-08-29T13:57:58.295022+00:00 app[web.1]: (node:4) ExperimentalWarning: 
The http2 module is an experimental API.
2018-08-29T13:57:58.732365+00:00 app[web.1]: Bot is ready!
2018-08-29T13:58:55.278962+00:00 heroku[web.1]: Error R10 (Boot timeout) -> 
Web process failed to bind to $PORT within 60 seconds of launch
2018-08-29T13:58:55.278962+00:00 heroku[web.1]: Stopping process with 
2018-08-29T13:58:55.404294+00:00 heroku[web.1]: Process exited with status 137
2018-08-29T13:58:55.623262+00:00 heroku[web.1]: State changed from starting to crashed

now if i try there soultion:

2018-08-29T14:07:46.618465+00:00 heroku[web.1]: Starting process with 
command `node bot.js`
2018-08-29T14:07:48.107034+00:00 heroku[web.1]: Process exited with status 1
2018-08-29T14:07:48.063674+00:00 app[web.1]: /app/bot.js:8
2018-08-29T14:07:48.063700+00:00 app[web.1]: app.listen(PORT, () => {
2018-08-29T14:07:48.063701+00:00 app[web.1]: ^
2018-08-29T14:07:48.063703+00:00 app[web.1]: 
2018-08-29T14:07:48.063704+00:00 app[web.1]: ReferenceError: app is not defined
2018-08-29T14:07:48.063706+00:00 app[web.1]:     at Object.<anonymous> 
2018-08-29T14:07:48.063707+00:00 app[web.1]:     at Module._compile 
2018-08-29T14:07:48.063709+00:00 app[web.1]:     at 
Object.Module._extensions..js (module.js:663:10)
2018-08-29T14:07:48.063711+00:00 app[web.1]:     at Module.load 
2018-08-29T14:07:48.063713+00:00 app[web.1]:     at tryModuleLoad 
2018-08-29T14:07:48.063714+00:00 app[web.1]:     at Function.Module._load 
2018-08-29T14:07:48.063716+00:00 app[web.1]:     at Function.Module.runMain 
2018-08-29T14:07:48.063718+00:00 app[web.1]:     at startup 
2018-08-29T14:07:48.063720+00:00 app[web.1]:     at bootstrap_node.js:612:3
2018-08-29T14:07:48.120800+00:00 heroku[web.1]: State changed from starting 
to crashed

also the script that i added:

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
    console.log(`Our app is running on port ${ PORT }`);

Answer seems that the error is that app is not defined.

I am assuming you are using the JS Express library, so make sure the Express library was correctly installed. Double check if you are importing it correctly into your program, and make sure to define const app = express();