Ask coding questions

← Back to all posts
How do i host on node.js and where do i input the code and what code?
ExoticCitron

Ok sorry im so new here, this might annoy you all but im really struggling, this discord music bot needs to stay online all the time but i dont know what code to put and where to put it on index.js as it doesnt work (host on uptimerobot??)

Someone please fork this and give me the code and where to put it please!!!

Or can someone just reply with the answers i have below???

also i think you guys can see the token and all, may someone tell me how to make it so that its hidden without any error on node.js??? THANKS!!

Very much appreciated!

Answered by 19wintersp [earned 5 cycles]
View Answer
Voters
ch1ck3n
Comments
hotnewtop
19wintersp

If you want it to stay on all the time, either ping "evobot.lumiscnt.repl.co" with UptimeRobot (or another similar service), or purchase Hacker Plan and use their new always-on feature.

To hide your token(s), create a file called ".env". Place your tokens in that file, one on each line, in the format <token name>=<token value>. Then, wherever you need to access it in your JS code, refer to process.env.<token name>.

This codebase is currently extracting its keys from "config.json". Modify "util/EvobotUtil.js" so that lines 12-18 are replaced with:

and add this to your ".env" file:

Add everything in "config.json" in that format. I have intentionally cut off TOKEN and YOUTUBE_API_KEY, though you should add these in full to your file.

ExoticCitron

@19wintersp

hey i still dont understand, sorry, im new to this! I made an '.env' file and put my tokens there and when i added this, it shows red. May you help me further or possibly , fork this?

Since i also dont understand the util/Evobot thing either??

So sorry!

19wintersp

@Lumiscnt I've updated my answer. (and please don't feel the need to apologise)

ExoticCitron

it shows token as red and it shows this on the [email protected]

19wintersp

@Lumiscnt I'll repeat two things:

Add everything in "config.json" in that format.

You need to add every part of "config.json" in the same format as the rest of the ".env" file.

Modify "util/EvobotUtil.js" so that lines 12-18 are replaced with:

You need to edit the file "util/EvobotUtil.js" as aforementioned.

19wintersp

@Lumiscnt I've also just noticed: that should be in the file named ".env", not in "config.json".

ExoticCitron

so for the add in config i add only this :

TOKEN="ODEw..."
YOUTUBE_API_KEY="AIza..."
SOUNDCLOUD_CLIENT_ID=""
MAX_PLAYLIST_SIZE=10
PREFIX="!"

(along with the rest of the token of course) and i copy and add the same thing for the .env file??? I did that

And i did modify the util/Evobot for lines 12-18 @19wintersp

ExoticCitron

so i delete the .env and rename util/evobot with .env?? @19wintersp

19wintersp

@Lumiscnt You're very nearly there. The next thing you need to do is delete "config.json". After you've done that, you will still need to modify your ".env". As I said in my original post, you will need to add all of the things which were originally in "config.json" to ".env" in the "<key>=<value>" format; that is "PRUNING", "LOCALE", "STAY_TIME" and "DEFAULT_VOLUME", in addition to the ones you've already added. The ellipsis was a placeholder where I intended for you to fill these in.

ExoticCitron

@19wintersp

I added it and deleted config.jsom, now what do i do??

Sorry for the late reply, wifi went down!

19wintersp

@Lumiscnt Please add the data in the same format as the original code, in the form of <key>=<value>.

ExoticCitron

<key>=<value> as in TOKEN=CODEGOESHERE? Sorry for being annoying ,im getting used to this!
@19wintersp

19wintersp

@Lumiscnt Yes, like that.

ExoticCitron

ok thanks! @19wintersp

ExoticCitron
xxpertHacker

First of all, do you know JavaScript? If so, how long have you known it?

ExoticCitron

not really, like i mentioned above, i started working on it and it wasnt workign well for me...

xxpertHacker

@Lumiscnt You can't make something in JavaScript if you don't know JavaScript.

Can you go write me an essay in German if you don't know German? No, obviously not!

Go learn JS first, you can't skip around like this.
Or, go find someone else to make the bot; there's plenty of configurable bots out there.

ExoticCitron

@xxpertHacker fine,sorry.All i really wanted to know is how to get the bot online since its working n' all but i didnt know about uptimerobot so i was pretty new to this concept.