mirror of
https://github.com/runyanjake/discord.git
synced 2025-10-04 15:27:28 -07:00
20 lines
547 B
Python
20 lines
547 B
Python
import json
|
|
import sys
|
|
|
|
TOKEN = 'token'
|
|
|
|
def get_token(file_path):
|
|
try:
|
|
with open(file_path, 'r') as file:
|
|
data = json.load(file)
|
|
if TOKEN in data:
|
|
return data[TOKEN]
|
|
else:
|
|
print("Bot token file missing " + str(TOKEN) + " field. See README.")
|
|
except FileNotFoundError:
|
|
print("No bot token file. See README.")
|
|
except json.JSONDecodeError:
|
|
print("Invalid JSON format for bot token file. See README.")
|
|
|
|
sys.exit(1)
|