1
0
Fork 0
mirror of synced 2024-05-07 06:02:24 +12:00

Added error checking to view the errors on loading, unloading modules

This commit is contained in:
Phxntxm 2016-07-09 09:57:57 -05:00
parent 0ca881d7cd
commit d45b3d4ff2

View file

@ -26,32 +26,44 @@ class Mod:
@checks.isAdmin()
async def load(self, *, module : str):
"""Loads a module"""
if not len(module) > 0:
await self.bot.say("Please provide a module!")
return
self.bot.load_extension(module)
await self.bot.say("I have just loaded the {} module".format(module))
try:
if not len(module) > 0:
await self.bot.say("Please provide a module!")
return
self.bot.load_extension(module)
await self.bot.say("I have just loaded the {} module".format(module))
except Exception as e:
fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```'
await bot.say(fmt.format(type(e).__name__, e))
@commands.command()
@checks.isAdmin()
async def unload(self, *, module : str):
"""Unloads a module"""
if not len(module) > 0:
await self.bot.say("Please provide a module!")
return
self.bot.unload_extension(module)
await self.bot.say("I have just unloaded the {} module".format(module))
try:
if not len(module) > 0:
await self.bot.say("Please provide a module!")
return
self.bot.unload_extension(module)
await self.bot.say("I have just unloaded the {} module".format(module))
except Exception as e:
fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```'
await bot.say(fmt.format(type(e).__name__, e))
@commands.command()
@checks.isAdmin()
async def reload(self, *, module : str):
"""Reloads a module"""
if not len(module) > 0:
await self.bot.say("Please provide a module!")
return
self.bot.unload_extension(module)
self.bot.load_extension(module)
await self.bot.say("I have just reloaded the {} module".format(module))
try:
if not len(module) > 0:
await self.bot.say("Please provide a module!")
return
self.bot.unload_extension(module)
self.bot.load_extension(module)
await self.bot.say("I have just reloaded the {} module".format(module))
except Exception as e:
fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```'
await bot.say(fmt.format(type(e).__name__, e))
def setup(bot):