Discord.js-Bot-Development
Discord.js-Bot-Development copied to clipboard
My bot can't find the .env file and stops running. Help!
When I click run my bot runs for 1 second then just stops running I've read some of the error code (don't really understand it) but I found can't find .env.
So basically, when you host on Glitch, you must have a file called .env (this file is created by Glitch on the creation of a new express app by default). This file is used to keep certain variables secret. These variables are stored inside an object called env which is stored inside another object called process. You can access your secret variables via process.env.
Here's a reference:

Here's how to access your variable:
client.login(process.env.TOKEN);
This means your index.js file doesn't need to look after .env file. If this wasn't the right solution to your question please comment with the error message you're getting (possibly with some references too). :+1: