reworking a bunch of stuff 2.0

This commit is contained in:
Nikolaj
2024-10-28 14:38:41 +01:00
parent bc59bf9b05
commit eb2960aa10
9 changed files with 21 additions and 269 deletions

View File

@ -1,11 +1,12 @@
from interactions import Client, Status
from gwendolyn.utils import get_options, get_credentials, long_strings, log
from gwendolyn.utils import log
from dotenv import load_dotenv
from os import getenv
from pymongo import MongoClient # Used for database management
class Gwendolyn(Client):
def __init__(self):
def __init__(self, testing: bool = True):
"""Initialize the bot."""
initiation_parameters = {
"status": Status.DND,
@ -13,6 +14,8 @@ class Gwendolyn(Client):
}
super().__init__(**initiation_parameters)
self.testing = testing
self._add_clients_and_options()
# self._add_util_classes()
# self._add_function_containers()
@ -20,16 +23,16 @@ class Gwendolyn(Client):
def _add_clients_and_options(self):
"""Add all the client, option and credentials objects."""
self.long_strings = long_strings()
self.options = get_options()
self.credentials = get_credentials()
mongo_user = self.credentials["mongo_db_user"]
mongo_password = self.credentials["mongo_db_password"]
load_dotenv()
self.bot_token = getenv("DISCORD_TOKEN")
mongo_user = getenv("MONGODB_USER")
mongo_password = getenv("MONGODB_PASSWORD")
mongo_url = f"mongodb+srv://{mongo_user}:{mongo_password}@gwendolyn"
mongo_url += ".qkwfy.mongodb.net/Gwendolyn?retryWrites=true&w=majority"
database_client = MongoClient(mongo_url)
if self.options["testing"]:
if self.testing:
self.log("Testing mode")
self.database = database_client["Gwendolyn-Test"]
else:
@ -37,4 +40,7 @@ class Gwendolyn(Client):
def log(self, messages, channel: str = "", level: int = 20): # pylint:disable=no-self-use
"""Log a message. Described in utils/util_functions.py."""
log(messages, channel, level)
log(messages, channel, level)
def start(self):
super().start(self.bot_token)