add yml config option
This commit is contained in:
6
config/config_example.yml
Normal file
6
config/config_example.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
token: ''
|
||||||
|
prefix: ''
|
||||||
|
|
||||||
|
...
|
||||||
@@ -1,13 +1,26 @@
|
|||||||
"""
|
"""
|
||||||
Gather all config data into one file
|
Gather all config data into one file,
|
||||||
|
so all other files can call it from here
|
||||||
|
|
||||||
loadconfig.py then gets called in aquabot.py
|
loadconfig.py then gets called in aquabot.py
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# IMPORTS
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
# Variable Gathering
|
||||||
__avatar__ = "https://i.imgur.com/mskM9dH.png"
|
__avatar__ = "https://i.imgur.com/mskM9dH.png"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# TODO Maybe use yaml for token and prefix!
|
with open("config/config.yml") as file:
|
||||||
|
config = yaml.safe_load(file)
|
||||||
|
for yml_entry in config:
|
||||||
|
__token__ = config[yml_entry]['token']
|
||||||
|
__prefix__ = config[yml_entry]['prefix']
|
||||||
|
except yaml.YAMLError as error:
|
||||||
|
print(f"Error while parsing: {error}")
|
||||||
|
|
||||||
|
try:
|
||||||
from config.config import __token__, __prefix__
|
from config.config import __token__, __prefix__
|
||||||
from config.cogs import __cogs__
|
from config.cogs import __cogs__
|
||||||
from config.status import __activity__
|
from config.status import __activity__
|
||||||
|
|||||||
Reference in New Issue
Block a user