aboutsummaryrefslogtreecommitdiff
path: root/code/global_variables.py
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-03-31 00:10:45 -0500
committerParker <contact@pkrm.dev>2024-03-31 00:10:45 -0500
commit39026bb4e0535d31f9436e6506a38e4be0b33f30 (patch)
tree0541f46a0a27763f657d0902d523b16a0905ee79 /code/global_variables.py
parent7e7f2d959cc1100604774fff78d4d67087629073 (diff)
base commit
Diffstat (limited to 'code/global_variables.py')
-rw-r--r--code/global_variables.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/code/global_variables.py b/code/global_variables.py
new file mode 100644
index 0000000..1bb4a7a
--- /dev/null
+++ b/code/global_variables.py
@@ -0,0 +1,56 @@
+import configparser
+import logging
+from colorlog import ColoredFormatter
+import discord
+
+
+log_level = logging.DEBUG
+log_format = (
+ " %(log_color)s%(levelname)-8s%(reset)s | %(log_color)s%(message)s%(reset)s"
+)
+
+logging.root.setLevel(log_level)
+formatter = ColoredFormatter(log_format)
+
+stream = logging.StreamHandler()
+stream.setLevel(log_level)
+stream.setFormatter(formatter)
+
+LOG = logging.getLogger("pythonConfig")
+LOG.setLevel(log_level)
+LOG.addHandler(stream)
+
+try:
+ with open("config.ini", "r") as f:
+ file_contents = f.read()
+except FileNotFoundError:
+ config = configparser.ConfigParser()
+ config["BOT_INFO"] = {
+ "TOKEN": "",
+ "BOT_COLOR": "",
+ }
+
+ config["LAVALINK"] = {
+ "HOST": "",
+ "PORT": "",
+ "PASSWORD": ""
+ }
+
+ with open("config.ini", "w") as configfile:
+ config.write(configfile)
+
+ LOG.error(
+ "Configuration file `config.ini` has been generated. Please fill out all of the necessary information. Refer to the docs for information on what a specific configuration option is."
+ )
+ exit()
+
+
+config = configparser.ConfigParser()
+config.read_string(file_contents)
+
+BOT_TOKEN = config["BOT_INFO"]["TOKEN"]
+BOT_COLOR = discord.Color(int((config["BOT_INFO"]["BOT_COLOR"]).replace("#", ""), 16))
+
+LAVALINK_HOST = config["LAVALINK"]["HOST"]
+LAVALINK_PORT = config["LAVALINK"]["PORT"]
+LAVALINK_PASSWORD = config["LAVALINK"]["PASSWORD"]