Fixed race condition
This commit is contained in:
parent
258afada1f
commit
2ab8e56a53
|
@ -17,25 +17,26 @@ class Logging():
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.request = bot.request
|
self.request = bot.request
|
||||||
|
self.online = bot.online
|
||||||
self.maintenance = bot.maintenance
|
self.maintenance = bot.maintenance
|
||||||
|
|
||||||
# Sets info hook first
|
# Sets info hook first
|
||||||
self.info_hook = self.bot.online.get_webhook(
|
self.info_hook = self.online.get_webhook(
|
||||||
bot.config['INFO_HOOK'] if bot.config['INFO_HOOK']
|
bot.config['INFO_HOOK'] if bot.config['INFO_HOOK']
|
||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
|
|
||||||
# Sets other hooks or defaults them
|
# Sets other hooks or defaults them
|
||||||
if self.info_hook:
|
if self.info_hook:
|
||||||
self.warn_hook = self.bot.online.get_webhook(
|
self.warn_hook = self.online.get_webhook(
|
||||||
bot.config['WARN_HOOK'] if bot.config['WARN_HOOK']
|
bot.config['WARN_HOOK'] if bot.config['WARN_HOOK']
|
||||||
else self.info_hook
|
else self.info_hook
|
||||||
)
|
)
|
||||||
self.error_hook = self.bot.online.get_webhook(
|
self.error_hook = self.online.get_webhook(
|
||||||
bot.config['ERROR_HOOK'] if bot.config['ERROR_HOOK']
|
bot.config['ERROR_HOOK'] if bot.config['ERROR_HOOK']
|
||||||
else self.info_hook
|
else self.info_hook
|
||||||
)
|
)
|
||||||
self.debug_hook = self.bot.online.get_webhook(
|
self.debug_hook = self.online.get_webhook(
|
||||||
bot.config['DEBUG_HOOK'] if bot.config['DEBUG_HOOK']
|
bot.config['DEBUG_HOOK'] if bot.config['DEBUG_HOOK']
|
||||||
else self.info_hook
|
else self.info_hook
|
||||||
)
|
)
|
||||||
|
@ -56,7 +57,7 @@ class Logging():
|
||||||
|
|
||||||
# Hastebins Traceback
|
# Hastebins Traceback
|
||||||
try:
|
try:
|
||||||
url = await self.bot.online.hastebin(
|
url = await self.online.hastebin(
|
||||||
''.join(original_exc))
|
''.join(original_exc))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
url = None
|
url = None
|
||||||
|
|
11
main.py
11
main.py
|
@ -44,9 +44,16 @@ class Bot(commands.Bot):
|
||||||
"""Initializes extensions."""
|
"""Initializes extensions."""
|
||||||
|
|
||||||
# Utils
|
# Utils
|
||||||
for ext in os.listdir('extensions/utils'):
|
|
||||||
|
# Avoids race conditions with online
|
||||||
|
utils_dir = os.listdir('extensions/utils')
|
||||||
|
if 'online.py' in utils_dir:
|
||||||
|
utils_dir.remove('online.py')
|
||||||
|
bot.load_extension('extensions.utils.online')
|
||||||
|
|
||||||
|
# Rest of utils
|
||||||
|
for ext in utils_dir:
|
||||||
if ext.endswith('.py'):
|
if ext.endswith('.py'):
|
||||||
print(ext)
|
|
||||||
try:
|
try:
|
||||||
bot.load_extension(f'extensions.utils.{ext[:-3]}')
|
bot.load_extension(f'extensions.utils.{ext[:-3]}')
|
||||||
self.extensions_list.append(
|
self.extensions_list.append(
|
||||||
|
|
Loading…
Reference in New Issue