added token input
This commit is contained in:
parent
dc6bb75922
commit
d8fdd74316
|
|
@ -103,7 +103,7 @@ celerybeat.pid
|
|||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
*.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
|
|
@ -137,3 +137,4 @@ dmypy.json
|
|||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
token.env
|
||||
|
|
|
|||
18
bot.py
18
bot.py
|
|
@ -2,6 +2,24 @@ import os
|
|||
import discord
|
||||
from dotenv import load_dotenv
|
||||
|
||||
|
||||
def checkEnv():
|
||||
print('Checking if token.env exists...')
|
||||
try:
|
||||
out_file = open('token.env')
|
||||
print('Token is ready!')
|
||||
except IOError:
|
||||
print('First you have to give us the Discord Token for your bot!')
|
||||
token = input('token: ')
|
||||
out_file = open('token.env', 'w')
|
||||
out_file.write(f'DISCORD_TOKEN={token}')
|
||||
finally:
|
||||
out_file.close()
|
||||
pass
|
||||
|
||||
|
||||
checkEnv()
|
||||
|
||||
load_dotenv("token.env")
|
||||
TOKEN = os.getenv('DISCORD_TOKEN')
|
||||
GUILD = os.getenv('DISCORD_GUILD')
|
||||
|
|
|
|||
Loading…
Reference in New Issue