Anyone know how to use .env?(discord.py)
tristandasavage

I'm trying to hide my token in a .env file so people can't get my bot's token, and I don't know how to get my token variable from the file.
ENV:
TOKEN=da token(not telling u lol)
PYTHON:
token = os.getenv("TOKEN")

I have a feeling that my code is wrong, but I don't know what the right code is.

You are viewing a single comment. View All
AloegelhiPlaysR

UH.. Delete secrets.env NOW. Your token is public right now! Make a new file called .env and do token=YOUR TOKEN

We have full access to it.

and yes, os.getenv("token") is correct.

tristandasavage
KHZ

@TristanMurphy You don't need to name the .env file. While adding a new file to the repl you just write as .env as the filename not vars.env.

AloegelhiPlaysR

Did I fix the issue? @TristanMurphy

AloegelhiPlaysR

Also please go here and regenerate your bot token! @AloegelhiPlaysR

tristandasavage

@AloegelhiPlaysR lol ik how to regen tokens

AloegelhiPlaysR

Just looking out for ya! @TristanMurphy