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.")
|
logging.fatal("Failed to create tables, due to MySQL connection configuration being unset.")
|
||||||
return
|
return
|
||||||
guilds: list[discord.Guild] = self.bot.guilds
|
guilds: list[discord.Guild] = self.bot.guilds
|
||||||
|
try:
|
||||||
for guild in guilds:
|
for guild in guilds:
|
||||||
await self.create_guild_table(guild)
|
await self.create_guild_table(guild)
|
||||||
|
except ConnectionRefusedError:
|
||||||
|
return
|
||||||
|
|
||||||
@commands.Cog.listener('on_guild_join')
|
@commands.Cog.listener('on_guild_join')
|
||||||
async def db_generate_guild_join(self, guild: discord.Guild):
|
async def db_generate_guild_join(self, guild: discord.Guild):
|
||||||
|
@ -47,7 +50,10 @@ class Moderation(commands.Cog):
|
||||||
if conf:
|
if conf:
|
||||||
logging.fatal("Failed to create a table for %s, due to MySQL connection configuration being unset.", guild.id)
|
logging.fatal("Failed to create a table for %s, due to MySQL connection configuration being unset.", guild.id)
|
||||||
return
|
return
|
||||||
|
try:
|
||||||
await self.create_guild_table(guild)
|
await self.create_guild_table(guild)
|
||||||
|
except ConnectionRefusedError:
|
||||||
|
return
|
||||||
|
|
||||||
async def connect(self):
|
async def connect(self):
|
||||||
"""Connects to the MySQL database, and returns a connection object."""
|
"""Connects to the MySQL database, and returns a connection object."""
|
||||||
|
@ -64,7 +70,7 @@ class Moderation(commands.Cog):
|
||||||
host=await self.config.mysql_address(),
|
host=await self.config.mysql_address(),
|
||||||
user=await self.config.mysql_user(),
|
user=await self.config.mysql_user(),
|
||||||
password=await self.config.mysql_password(),
|
password=await self.config.mysql_password(),
|
||||||
database=await self.config.mysql_db()
|
database=await self.config.mysql_database()
|
||||||
)
|
)
|
||||||
return connection
|
return connection
|
||||||
except mysql.connector.ProgrammingError as e:
|
except mysql.connector.ProgrammingError as e:
|
||||||
|
|
Loading…
Reference in a new issue