diff --git a/moderation/moderation.py b/moderation/moderation.py index 1ba0a79..142dea7 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -22,6 +22,15 @@ class Moderation(commands.Cog): async def cog_load(self): """This method prepares the database schema for all of the guilds the bot is currently in.""" + conf = await self.check_conf([ + 'mysql_address', + 'mysql_database', + 'mysql_user', + 'mysql_password' + ]) + if conf: + logging.fatal("Failed to create tables, due to MySQL connection configuration being unset.") + return guilds: list[discord.Guild] = self.bot.guilds for guild in guilds: await self.create_guild_table(guild) @@ -29,6 +38,15 @@ class Moderation(commands.Cog): @commands.Cog.listener('on_guild_join') async def db_generate_guild_join(self, guild: discord.Guild): """This method prepares the database schema whenever the bot joins a guild.""" + conf = await self.check_conf([ + 'mysql_address', + 'mysql_database', + 'mysql_user', + 'mysql_password' + ]) + if conf: + logging.fatal("Failed to create a table for %s, due to MySQL connection configuration being unset.", guild.id) + return await self.create_guild_table(guild) async def connect(self): @@ -40,7 +58,7 @@ class Moderation(commands.Cog): 'mysql_password' ]) if conf: - raise LookupError + raise LookupError("MySQL connection details not set properly!") try: connection = mysql.connector.connect( host=await self.config.mysql_address(),