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
Answered by AloegelhiPlaysR [earned 5 cycles]
View Answer
AloegelhiPlaysR

@TristanMurphy Here, join the team I invited you to. I'll help ya out for a sec. You'll be surprised.

tristandasavage

@AloegelhiPlaysR didnt get an invite

tristandasavage

@AloegelhiPlaysR btw is there a chance that you know how I can run it 24/7 using uptimerobot? I already have it configured in the dashboard, but I paused it so I could fix this. I noticed that when I run it, I get an error after it says updating discord.py:
Traceback (most recent call last):
File "main.py", line 169, in <module>
client.run(token)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 708, in run
return future.result()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 687, in runner
await self.start(args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 650, in start
await self.login(
args, bot=bot)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 499, in login
await self.http.static_login(token.strip(), bot=bot)
AttributeError: 'NoneType' object has no attribute 'strip'

tristandasavage

lol nvm im an idiot and put DISCORD_BOT_TOKEN instead of DISCORD_BOT_SECRET which was in the variable lol

AloegelhiPlaysR