diff --git a/config.py b/config.py index 21eb1e4..dcba7ca 100644 --- a/config.py +++ b/config.py @@ -1,3 +1,7 @@ +""" +Loads environment variables for use in bot. +""" + import os from dotenv.main import load_dotenv @@ -5,5 +9,9 @@ from dotenv.main import load_dotenv load_dotenv() # Discord config -DISCORD_TOKEN = os.getenv("DISCORD_TOKEN", "") BOT_PREFIX = "?" +DISCORD_TOKEN = os.getenv("DISCORD_TOKEN", "") +SQL_DB = os.getenv("SQL_DB", "") +SQL_HOST = os.getenv("SQL_HOST", "") +SQL_PASS = os.getenv("SQL_PASS", "") +SQL_USER = os.getenv("SQL_USER", "") diff --git a/highscores.py b/highscores.py index 45f1ace..7282c03 100644 --- a/highscores.py +++ b/highscores.py @@ -1,16 +1,16 @@ """ -main file for pvm-highscores bot +main file for highscores bot """ import logging import os import sys -from nextcord.ext import commands +import mysql.connector import nextcord +from nextcord.ext import commands import config -from classes.highscores_data import HighscoresData from classes.submission import SubmissionMap logger = logging.getLogger("nextcord") @@ -19,14 +19,10 @@ handler = logging.FileHandler(filename="nextcord.log", encoding="utf-8", mode="w handler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s")) logger.addHandler(handler) - -highscores_data: HighscoresData = HighscoresData() -highscores_message_map = {} - -for guild in highscores_data.guilds: - highscores_message_map[guild.guild_id] = {} - for table in guild.tables: - highscores_message_map[guild.guild_id][table.message_id] = table.name +highscores_db = mysql.connector.connect( + host=config.SQL_HOST, user=config.SQL_USER, password=config.SQL_PASS, database=config.SQL_DB +) +highscores_cursor = highscores_db.cursor() submission_objects: SubmissionMap = SubmissionMap()