Heroku Discord Bot Error

Hey!

This post is regarding my new moderation bot, mystical. I will be hosting it on heroku but I have an error!

I belive this is because I put my token in github secrets and didnt set up my index.js up right but idk how I do that.

The logs:

2022-08-02T15:43:04.368216+00:00 app[web.1]: npm ERR! 
2022-08-02T15:43:04.368249+00:00 app[web.1]: npm ERR! To see a list of scripts, run:
2022-08-02T15:43:04.368342+00:00 app[web.1]: npm ERR!   npm run
2022-08-02T15:43:04.369896+00:00 app[web.1]: 
2022-08-02T15:43:04.370043+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2022-08-02T15:43:04.370094+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2022-08-02T15_43_04_313Z-debug-0.log
2022-08-02T15:43:04.486032+00:00 heroku[web.1]: Process exited with status 1
2022-08-02T15:43:04.681768+00:00 heroku[web.1]: State changed from starting to crashed
2022-08-02T15:43:15.371266+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mystical-discord-bot.herokuapp.com request_id=2b45fec3-6391-4137-aaf6-01bab842627e fwd="not my ip" dyno= connect= service= status=503 bytes= protocol=https
2022-08-02T15:43:15.958977+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=mystical-discord-bot.herokuapp.com request_id=5ad19ec7-578a-49ef-b56a-9792d0dd03f3 fwd="not my ip again" dyno= connect= service= status=503 bytes= protocol=https
2022-08-02T15:42:55.160579+00:00 app[api]: Release v3 created by user my email, no
2022-08-02T15:42:55.160579+00:00 app[api]: Deploy 423b4313 by user my email, no
2022-08-02T15:42:55.174667+00:00 app[api]: Scaled to web@1:Free by user my email, no
2022-08-02T15:42:55.000000+00:00 app[api]: Build succeeded

My GitHub repo: GitHub - lukeiscoolio/mystical-bot

This is in JS therefore I’m very weak. But your getting your token from: const { token } = require('./config.json');.

config.json doesn’t exist so it’s impossible your getting your token from there.

Then what do I put there since its now in github secrets, will I have to use a .env file?

To get the token you can do something like:

${{ secrets.SecretName}}

I put in a pull request for you.

Update index.js by CookieHax · Pull Request #1 · lukeiscoolio/mystical-bot (github.com)

Try give it a go, it may be that that only works in github actions, but it’s worth a go.

1 Like

New error in logs i think

2022-08-02T15:58:19.412853+00:00 heroku[web.1]: State changed from starting to crashed

2022-08-02T15:58:20.000000+00:00 app[api]: Build started by user no not my email

2022-08-02T15:58:28.197513+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mystical-discord-bot.herokuapp.com request_id=f30f2fc8-12dc-4304-a5c7-5ea4bceb625e fwd="no" dyno= connect= service= status=503 bytes= protocol=https

2022-08-02T15:58:28.639816+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=mystical-discord-bot.herokuapp.com request_id=fdc5e8dd-6959-4be4-9da6-a5f392be7f22 fwd="no" dyno= connect= service= status=503 bytes= protocol=https

2022-08-02T15:58:39.000000+00:00 app[api]: Build succeeded

2022-08-02T15:58:39.174223+00:00 app[api]: Deploy f06eb45e by user no

2022-08-02T15:58:39.174223+00:00 app[api]: Release v5 created by user no

2022-08-02T15:58:40.397927+00:00 heroku[web.1]: State changed from crashed to starting

2022-08-02T15:58:42.603928+00:00 heroku[web.1]: Starting process with command `npm start`

2022-08-02T15:58:45.224835+00:00 heroku[web.1]: Process exited with status 1

2022-08-02T15:58:45.077890+00:00 app[web.1]: npm ERR! Missing script: "start"

2022-08-02T15:58:45.078130+00:00 app[web.1]: npm ERR!

2022-08-02T15:58:45.078293+00:00 app[web.1]: npm ERR! Did you mean one of these?

2022-08-02T15:58:45.078398+00:00 app[web.1]: npm ERR! npm star # Mark your favorite packages

2022-08-02T15:58:45.078588+00:00 app[web.1]: npm ERR! npm stars # View packages marked as favorites

2022-08-02T15:58:45.078684+00:00 app[web.1]: npm ERR!

2022-08-02T15:58:45.078770+00:00 app[web.1]: npm ERR! To see a list of scripts, run:

2022-08-02T15:58:45.078953+00:00 app[web.1]: npm ERR! npm run

2022-08-02T15:58:45.081225+00:00 app[web.1]:

2022-08-02T15:58:45.081492+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:

2022-08-02T15:58:45.081607+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-08-02T15_58_45_003Z-debug-0.log

Hold on, are you trying to run your app as a web application?

I don’t know how you use heroku that much. So I don’t know.

Yeh,

Get requests normally mean web app, I’ve gone ahead and made another request adding a “Procfile”, this will tell your app to run.

worker: node index.js

Means that your app will run index.js with node, go ahead and accept the pull request:

Create Procfile by CookieHax · Pull Request #2 · lukeiscoolio/mystical-bot (github.com)

Is this good or bad?

2022-08-02T16:05:13.497251+00:00 app[web.1]: npm ERR!     npm star # Mark your favorite packages
2022-08-02T16:05:13.497354+00:00 app[web.1]: npm ERR!     npm stars # View packages marked as favorites
2022-08-02T16:05:13.497397+00:00 app[web.1]: npm ERR! 
2022-08-02T16:05:13.497434+00:00 app[web.1]: npm ERR! To see a list of scripts, run:
2022-08-02T16:05:13.497533+00:00 app[web.1]: npm ERR!   npm run
2022-08-02T16:05:13.499067+00:00 app[web.1]: 
2022-08-02T16:05:13.499221+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2022-08-02T16:05:13.499270+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2022-08-02T16_05_13_434Z-debug-0.log
2022-08-02T16:05:13.632734+00:00 heroku[web.1]: Process exited with status 1
2022-08-02T16:05:13.725512+00:00 heroku[web.1]: State changed from starting to crashed
2022-08-02T16:05:09.139332+00:00 app[api]: Deploy eecd909b by user no
2022-08-02T16:05:09.139332+00:00 app[api]: Release v6 created by user no
2022-08-02T16:05:09.000000+00:00 app[api]: Build succeeded

It worked?

Build succeeded

The bot isn’t online though.
image

Try to get heroku logs?

Theres more

2022-08-02T16:11:55.447659+00:00 heroku[web.1]: State changed from crashed to starting
2022-08-02T16:11:58.234943+00:00 heroku[web.1]: Starting process with command `npm start`
2022-08-02T16:12:00.712873+00:00 heroku[web.1]: Process exited with status 1
2022-08-02T16:12:00.538163+00:00 app[web.1]: npm ERR! Missing script: "start"
2022-08-02T16:12:00.538388+00:00 app[web.1]: npm ERR! 
2022-08-02T16:12:00.538599+00:00 app[web.1]: npm ERR! Did you mean one of these?
2022-08-02T16:12:00.538691+00:00 app[web.1]: npm ERR!     npm star # Mark your favorite packages
2022-08-02T16:12:00.538837+00:00 app[web.1]: npm ERR!     npm stars # View packages marked as favorites
2022-08-02T16:12:00.538906+00:00 app[web.1]: npm ERR! 
2022-08-02T16:12:00.538990+00:00 app[web.1]: npm ERR! To see a list of scripts, run:
2022-08-02T16:12:00.539168+00:00 app[web.1]: npm ERR!   npm run
2022-08-02T16:12:00.541433+00:00 app[web.1]: 
2022-08-02T16:12:00.541675+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2022-08-02T16:12:00.541757+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2022-08-02T16_12_00_456Z-debug-0.log
2022-08-02T16:12:01.044687+00:00 heroku[web.1]: State changed from starting to crashed

Error seems to be here.

Yeh, no start script.

Whats a start script?

No idea, something to do with JS.

I have fixed the issue now! I just made a separate repo with the config.json file. Could someone lock this please?

It will lock it’s self.

1 Like

This topic was automatically closed after 7 days. New replies are no longer allowed.