Added error checking to view the errors on loading, unloading modules
This commit is contained in:
parent
0ca881d7cd
commit
d45b3d4ff2
44
cogs/mod.py
44
cogs/mod.py
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue