fix(moderation): fixed the connect method
Some checks failed
Pylint / Pylint (push) Failing after 1m14s
Some checks failed
Pylint / Pylint (push) Failing after 1m14s
This commit is contained in:
parent
9f6cc2968f
commit
dbb02c0892
1 changed files with 10 additions and 4 deletions
|
@ -32,8 +32,11 @@ class Moderation(commands.Cog):
|
|||
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)
|
||||
try:
|
||||
for guild in guilds:
|
||||
await self.create_guild_table(guild)
|
||||
except ConnectionRefusedError:
|
||||
return
|
||||
|
||||
@commands.Cog.listener('on_guild_join')
|
||||
async def db_generate_guild_join(self, guild: discord.Guild):
|
||||
|
@ -47,7 +50,10 @@ class Moderation(commands.Cog):
|
|||
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)
|
||||
try:
|
||||
await self.create_guild_table(guild)
|
||||
except ConnectionRefusedError:
|
||||
return
|
||||
|
||||
async def connect(self):
|
||||
"""Connects to the MySQL database, and returns a connection object."""
|
||||
|
@ -64,7 +70,7 @@ class Moderation(commands.Cog):
|
|||
host=await self.config.mysql_address(),
|
||||
user=await self.config.mysql_user(),
|
||||
password=await self.config.mysql_password(),
|
||||
database=await self.config.mysql_db()
|
||||
database=await self.config.mysql_database()
|
||||
)
|
||||
return connection
|
||||
except mysql.connector.ProgrammingError as e:
|
||||
|
|
Loading…
Reference in a new issue